From owner-svn-src-head@freebsd.org Mon Jan 8 16:13:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F4133E74FED for ; Mon, 8 Jan 2018 16:13:47 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B232A82D1D for ; Mon, 8 Jan 2018 16:13:47 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x22d.google.com with SMTP id x67so14712220ioi.9 for ; Mon, 08 Jan 2018 08:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=U2dO0pIfCdQu/wrL3eiThJHNpORugumxOOcai+t91Ao=; b=L86bI7P+kyp0LqV6YMiQ+YTEv8a4rDczkiL0jqGKT7983zkAbIXeflpwG/CLqK+TEN BzRuTNa2+KuaF8o5jjL9buJxYGB8udKyyqziVOfOB7oX2PS17RsCo3XCtRG1iS1XZfSE eGFotCJlNSoKvfsXM6t60+p9xAnDOWxA5kJrN3/2sjhBeAOA3vTc5tXbCCjvWpI1wpwL 4UaeJEhqVQ6Zdc10qtmErOKwzTDS1AKGEtRhZFLbr3Lw6+gm3jW4Lz6N5F7IGJdYFY/l oqpwEANhtwoSMoThcbcvqb6vn732rDe9AXR9MCOO5Ri1SKcCzng39pl056psCr1jtIzm Inqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=U2dO0pIfCdQu/wrL3eiThJHNpORugumxOOcai+t91Ao=; b=RNuK2uF2Q+TgMO2yLgAYiVwY2MEXoNoMRkT6S7omtd5HCqzcZy3293h/OmPq4eL0f8 QO0SI7z1GkKPSKm+VPyMKy4clQ9KEXOcZUqetfhAHKy8F66C/Z31zBS+jt4XqWT2SKE3 4F7qp0TCPrcttYee+52LjgC4/xx2jx2JDi9KOfqMJVkFa3OwiECcXzTd32Q3+No432CS Wb4J0ex02ZjnGesyTwJkwLAniWc4mOA9DtmQSbqs/GIhe2CJi0RchBu3WiBLuQPTUMPh 6SVXBdspz1l7fxce/G4fuQ4IziBHR+ZMPRe2K41WegM2BmtjceAgJLmC5ywC3iXsqIpW 64Ng== X-Gm-Message-State: AKGB3mL9o0EEhKzuwho9NSgqK3kezAyreED99f08NKwEsjdEyNheXzz/ O8Y6jNwqUFKPhv9iMOSPJR2wCLzQRaLAU0yqtgQsPQ== X-Google-Smtp-Source: ACJfBos8I1+y5+c194BRf/4iuCmIysd4xsSPPVcrHvm4+Y6bEMTNquMhBzJbmlGemSIr7m2JAvabxw0JbWVL45FV9tI= X-Received: by 10.36.3.144 with SMTP id e138mr12011934ite.97.1515428027019; Mon, 08 Jan 2018 08:13:47 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.160.217 with HTTP; Mon, 8 Jan 2018 08:13:46 -0800 (PST) X-Originating-IP: [2603:300b:6:5100:a84a:1e5c:a3af:9943] Received: by 10.79.160.217 with HTTP; Mon, 8 Jan 2018 08:13:46 -0800 (PST) In-Reply-To: <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> From: Warner Losh Date: Mon, 8 Jan 2018 09:13:46 -0700 X-Google-Sender-Auth: 2GrbBeM6NyxWZTmwilXOd65Ynnw Message-ID: Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 To: Pedro Giffuni Cc: Ed Schouten , Andrew Turner , Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 16:13:48 -0000 On Jan 8, 2018 8:37 AM, "Pedro Giffuni" wrote: On 01/08/18 10:13, Ed Schouten wrote: > Hi Andrew, > > 2018-01-08 8:37 GMT+01:00 Andrew Turner : > >> Won=E2=80=99t this lead to a NULL pointer dereference on overflow? mallo= carray >> can return NULL even with M_WAITOK. >> > Yes, it will, but an overflow shouldn't happen in the first place. > ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an > overflow would happen, this would cause a kernel panic due to a NULL > pointer dereference later on, which is likely easier to debug than > some piece of code that overruns a buffer. > > In this case, mallocarray() is preferred, because it makes it more > obvious that we're allocating a buffer that is accessed as an array, > as opposed to single structure. > > OK... The behavior of mallocarray() somewhat inconsistent with malloc(9), realloc(9) and reallocf(9) but this is clearly documented., so we just assume the developer knows what he/she is doing :). This is one reason it didn't go in before... the error semantics suck... we re are a poor match for existing code. Warner