From owner-svn-src-all@freebsd.org Mon Jan 8 15:14:14 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 6353BE71D89 for ; Mon, 8 Jan 2018 15:14:14 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yb0-x232.google.com (mail-yb0-x232.google.com [IPv6:2607:f8b0:4002:c09::232]) (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 21BDB7F876 for ; Mon, 8 Jan 2018 15:14:14 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yb0-x232.google.com with SMTP id j7so4627233ybl.3 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=rFK7jHweVzz0f1tSUIKPltZFuguIK9ffbU5rBi+7VW6ubXmudVEuqW/2ktvoOmESDu woG/DZaKlGYRU0VS0F+K5ppzJQVSLwk4UnDtkXSPqBKvTFCHjIgru/9go81kCfdSh5Vs vS62GTAqW20Xo7bbfuSXGasM/o0hRdMROHSmu15X/AX5Vqsud0uBS6RCRO/eyzc6wDa+ 4UvkPUHqjgNfZHx7T91YDCrXjV1LG4NjlA2p1CIsO6JrPu3TbyW8ecowKAM1kwqGe6Hf Lb9vf6dZN2ohOJKyCSYhE5/0EiCACyJSI60BNfmTZjz0G9DTqvqAYThU3VQUTCqQGB7z RfNw== X-Gm-Message-State: AKGB3mJlEIgVknu3ce5X56tDY0OWXnH3ClSW9UaWyJsKYXUN1GAGsRdj Qw83CSLXJ2QfbLW2t+trJ0hkknf5GVXf1GpejMrV9A== 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-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 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