From owner-svn-src-all@freebsd.org Mon Jan 8 16:13:48 2018 Return-Path: Delivered-To: svn-src-all@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 F4167E74FEE for ; Mon, 8 Jan 2018 16:13:47 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x235.google.com (mail-io0-x235.google.com [IPv6:2607:f8b0:4001:c06::235]) (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 B25F782D1E for ; Mon, 8 Jan 2018 16:13:47 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x235.google.com with SMTP id w188so14727956iod.10 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=HCPEmccz/02U4Y4cl3Y0Vwnk13duvj/dj4LGCD33Kmfb01cV9l7P7HXB0JCvrMt4RW cummNar8EE0m56zO1+ANQvVEHlhsa3yioDh/p18sdGJIVCmnsP/NCOYfylwr6Qm1qZEx /RIZiK8yZ+HePOePPfNvVoFh34OI9XKlkR5JilzI/lv05hhbccp3kw+Qz8taVpNS26Ml 117y/Hs8R0DvG7ctGEDMESUlEBXv9qnBZsgSjrRXPemF3zL9wA3u2Was8HbQBkG8goLw EM0EdwLGo6QttaT/l1U+s9/A8Er2eVvzXiKo9Gk1Z8ZPwSsNh/prVDe0A0m60S4eW5g6 4nhw== X-Gm-Message-State: AKGB3mKq+ubk2fJ6W+mI/mntAgPE6sDH6lSWWyqD3ByF5swYiAwxb00j usiAUjNVSVw5gLKPhaglLByVfJyEiEHFcNrhX2UWnQ== 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-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" 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