Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5993369rdb; Sun, 17 Sep 2023 23:57:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpC+rMEQR9DlVJl7dF6Wp5+Sthhq7LGzq4A+e/qtogtokeKSuLig8bK3KaWLobYeoZioUL X-Received: by 2002:a17:90b:3b42:b0:262:ee7d:2d20 with SMTP id ot2-20020a17090b3b4200b00262ee7d2d20mr7762634pjb.12.1695020270243; Sun, 17 Sep 2023 23:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695020270; cv=none; d=google.com; s=arc-20160816; b=FJprHt1ONOq6Qc9YIv/CydQ9/hqFnQWOU4z72etAkBHmmpeWwcc5QiftySpXRLkUez Fg7Rp8LnNhZLSdoUF4Ks9udbdAbDa02IbkfmvKj9VNGBRSwSHzRWv8nQBqmiJsGmhKeH lkQR/15YJSXFrnq8JhTJpN2boiUEDCJNIkIFpEUu/hJ29Zvd3tm/jYDDiCBd1rMla+oZ 8S1oytyB6i2uGrMd1E2W0ZbzuLNEXNFBuolIUYgPrPnCKFAos1FN8ZPvdLDqgl20wcM2 eSO1JMqBQM91h0rg7YSxbzvN7DpRWeWM9XRCR4Sc6jbkzkdya1g+RjBk98w0wOovGuel yneA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9OlhErA4wMjFo3JkL2J3a2NrScsn7LO94sReLKNOXdw=; fh=KYfgvWAId5mrChDObNSL6Ouo3dNOsn8BdSJyBeank+w=; b=UPZ4U0n6NyNXmwAIcSj2XuC1CHAKeqLE6lvNuKmsVBuQoeerHHKKiUqdN/RsOWEolE c3x4M0Xyn8Lk0wqcwHuKmqrJEisvU+XwCGv4JyiPuCnnNSCobo+NyJu6Suj+I9HUsGWL VBCwlFCSVsOFPadmtHE6f/Wxx2cVBqzqTYdDK1Ja4k3jQbJ9fkO/b5piN5s2UXRGkXem zqiPKzgTMrd9TUY/ZUCHOKm7J80+xVpkrHU0yzkJq4Ag5OdKAXFVlDQGxTNZzKGuDS3y yQKIcm3mPw7HHPHS/i/PCkfjA8CoJ5kDOK+H5h7GWpWW3S4jVt15d4KdtCllJYmIY2gI vbeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id np9-20020a17090b4c4900b002718a9bad0bsi8045888pjb.36.2023.09.17.23.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 23:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BE6B38032004; Sun, 17 Sep 2023 23:56:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239871AbjIRG4L (ORCPT + 99 others); Mon, 18 Sep 2023 02:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239854AbjIRGzz (ORCPT ); Mon, 18 Sep 2023 02:55:55 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4544EC6; Sun, 17 Sep 2023 23:55:49 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="382323755" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="382323755" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 23:55:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="695417720" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="695417720" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga003.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 23:55:30 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qi8AI-0000000DVlr-18aJ; Mon, 18 Sep 2023 09:55:26 +0300 Date: Mon, 18 Sep 2023 09:55:25 +0300 From: Andy Shevchenko To: Dan Carpenter Cc: Philipp Stanner , Kees Cook , Eric Biederman , Christian Brauner , David Disseldorp , Luis Chamberlain , Siddh Raman Pant , Nick Alcock , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Zack Rusin , VMware Graphics Reviewers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-hardening@vger.kernel.org, David Airlie Subject: Re: [PATCH v2 1/5] string.h: add array-wrappers for (v)memdup_user() Message-ID: References: <93001a9f3f101be0f374080090f9c32df73ca773.1694202430.git.pstanner@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 17 Sep 2023 23:56:48 -0700 (PDT) On Sat, Sep 16, 2023 at 05:32:42PM +0300, Dan Carpenter wrote: > On Fri, Sep 08, 2023 at 09:59:40PM +0200, Philipp Stanner wrote: ... > > +static inline void *memdup_array_user(const void __user *src, size_t n, size_t size) > > +{ > > + size_t nbytes; > > + > > + if (unlikely(check_mul_overflow(n, size, &nbytes))) > > + return ERR_PTR(-EOVERFLOW); > > No need for an unlikely() because check_mul_overflow() already has one > inside. Makes sense. > I feel like -ENOMEM is more traditional but I doubt anyone/userspace > cares. ENOMEM is good for the real allocation calls, here is not the one (the one is below). Hence ENOMEM is not good candidate above. And whenever functions returns an error pointer the caller must not assume that it will be only ENOMEM for allocators. > > + return memdup_user(src, nbytes); > > +} -- With Best Regards, Andy Shevchenko