From owner-svn-src-head@freebsd.org Mon Jan 8 15:14:14 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 7628DE71D8A for ; Mon, 8 Jan 2018 15:14:14 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yb0-x22e.google.com (mail-yb0-x22e.google.com [IPv6:2607:f8b0:4002:c09::22e]) (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 317A37F879 for ; Mon, 8 Jan 2018 15:14:14 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yb0-x22e.google.com with SMTP id f16so4629454ybn.0 for ; Mon, 08 Jan 2018 07:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1vKUdDJF2q8Lg0HRJf6EmQK7A3e4gIX0T7O9lmc8wpM=; b=totnRVf9t4/2iTDP70DxOfw+qYHmQPLICZBhFf+9HP04t8zdDPkJf8w1tBUs26KXSI FkSVYRiszeOCqwWKueHftOjHvYV+TEnb0PqXto5B3r3ZTV1ZIBVo16M07s1WadmS6d6d yoVCra1G3qF/rxSTJEWiQbKmkJ0Te6Ouv4OKLkFLlnd3INBusyR9hjwWhLeBekBaj7ux hsWWIy2k+jLcGV2PuvRe9eC44X/l+s6lXIsqqaWoCVJFgwyrEZB0F13jtEjoAwNYsXuk TQVAVGkO5PlYEtQYa5AEaIUT8vADu7zdKFfu5Dl+btFoXXWai7rnla5rBX74U58hKxgE CJ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1vKUdDJF2q8Lg0HRJf6EmQK7A3e4gIX0T7O9lmc8wpM=; b=UwGwNqR475DTngYHFeQlm40QVk4Nils6ksOxTp7WsEL7lIJZ47nHGhIVvry5m3Lvmk ZsFbb/FIO0VS/LpfHaqDggNnSLMTHVir5CAsEjueqAd/WKJlZtm8IBvzNyXUE7mqFddD O86McSRw4F3aAnor2ol00Lh4PKsyBlpbvi/gVIIr6Ix2AxBZaOLKEJjrG5Dwnn2Xur9z ZyJtI/Cl4u5VIIUbHNAKuR0NrfAzKEhroWPbsN9ngxqtjBH4lT38e/6tO/tuHSvr1ppv IywK63WWTGWzTU0YQFboweXXntByrht59dB9wxeo+G1ZIJEEKGbKerE3w89c5NByixia SCUg== X-Gm-Message-State: AKGB3mI58l17P9/YDlHnR71m+KHLoDW2qOelx2V57dHeN5Cx2p0zGDpN PnuDMRH9zA0Z8ZG4P0af6cbmsiKZp254jUVFVrzLow== X-Google-Smtp-Source: ACJfBouCUzYvMazQcVThk+pW/bwJWC9QEbRbMNrdrwKX8JSv++2Q6BzRBS0bD9+QeZHZACTdBKOIBm09a+gsbH2fLqY= X-Received: by 10.37.239.5 with SMTP id g5mr1841433ybd.226.1515424453231; Mon, 08 Jan 2018 07:14:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.85.17 with HTTP; Mon, 8 Jan 2018 07:13:42 -0800 (PST) In-Reply-To: <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> From: Ed Schouten Date: Mon, 8 Jan 2018 16:13:42 +0100 Message-ID: Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 To: Andrew Turner Cc: 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-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 15:14:14 -0000 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? malloc= array 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. --=20 Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands