Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6094279rdb; Mon, 18 Sep 2023 04:13:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBPxINtwSpV3TUz+PC6PyPlb1fZ9rWIDtNZyplbZ1vC0lCv3+PeSn73xl5CvQwdkU7mEda X-Received: by 2002:a17:90a:300e:b0:274:922d:4b35 with SMTP id g14-20020a17090a300e00b00274922d4b35mr6494129pjb.1.1695035592388; Mon, 18 Sep 2023 04:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695035592; cv=none; d=google.com; s=arc-20160816; b=Ae1Yh2bd9gk2XW8AAda1Lq42HM5Sw4lDEG9qpy+cOx18jtiUFovHd6AytLiUM8rgfl 6ZibN7WGQ5Ftses4ELDWygZdEwQSMM2+OrXBOGClgMwrVSddzmDeSwq33+/cNZqFm3gK Zcz5mHotKICVI8ZrGQx6mHyVYV25D8WV0TZNURhHTVhYRabMcLxQ/nDqzNxZJVvetoy6 gC72m/syO/1YoA7bTZ1HHC1DNHzzQEJuTC+Wer92ny5mQ7yJPUuO3zf3Us7YEHVodknE lFinYsJB4EG4vYdOtBiYyQamWRAIiHG8cD2+B7VPoWDj/9KopDU2ICymw3xf3HivZcOD zaKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=ySETEWMBBYemMdp3jyvFHrMDlDasjAvK3U0xoCA3NQU=; fh=LhmzCSrAELV7a430uTTk4uEsJFh6S0FldHKTzxYp0Ek=; b=nso3N99Ax7Z/6aaYWVX5lwBzVbnvMcfShYP7K7tINRLp163g8dQi6m/riTcm4N2cSl zTk3PXmm7fTfRWMOucEdvNPsKr6t6j1rvD4y5yru6pmJNLNMr1+lHeG2RwZCOZBdQl0o XRKIQQSFdZZ1LbLpzfLqmBX4ijm6z6VXWK5FQAlBqfkmT/RBHL4D/cusudeLqjQDVojZ j5b4rzg6dK278C+/bRVDMy1BwsvFAI3oVwWytyCrNwu3D9feweObV5TaCymygcvFozAo LJp+p9SVy8NO+hRjaXNAUXkmgwDGNSzvUVTsUUA7irVDzUY0V9iRf7H/SZbVqx+lzrHO IOCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cd42VR+R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h11-20020a170902f54b00b001bdad5f0f0bsi8206960plf.543.2023.09.18.04.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:13:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cd42VR+R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1B2B880740C1; Mon, 18 Sep 2023 02:15:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235056AbjIRJPO (ORCPT + 99 others); Mon, 18 Sep 2023 05:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238676AbjIRJOs (ORCPT ); Mon, 18 Sep 2023 05:14:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10D1910F for ; Mon, 18 Sep 2023 02:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695028434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ySETEWMBBYemMdp3jyvFHrMDlDasjAvK3U0xoCA3NQU=; b=cd42VR+RzlMdxl2zq5h68JxAWA8yz9ZBAJOKiUVT3dhi3Lh3XLe7PsYjrzdRkGYwBOj9Zg RQ5B9x9uDHJvs+J7Ose05SKJ2WJjpmWVxfvQlBQ2QwXTknFhm9r27dysILszFa1kVglnSs Lg2Q1OKi5RFTi1boQdgEFkBDB2qbXMY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-280-Uz9Fh3RlO56roIsFype9dg-1; Mon, 18 Sep 2023 05:13:51 -0400 X-MC-Unique: Uz9Fh3RlO56roIsFype9dg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-404daa4f5a7so7379615e9.1 for ; Mon, 18 Sep 2023 02:13:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695028430; x=1695633230; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ySETEWMBBYemMdp3jyvFHrMDlDasjAvK3U0xoCA3NQU=; b=pKSs/Zf4oVmz8AT+cNp1woTte3ZKjgk2l0EbJ0SRrpNO4grxQqYRFo6y7yIBShFfB+ bHKOtCe7Gjf5c58PFwbYWNxsvk+bSsNI884levpPld+KTI+5C5lS813WkaAosZrBh1dX EwFPqHEyEuSk+mqyte6HL5zOEpIFNFivuGqzF3RAwsL3eEVfiitfgh245MI8Y2ql6Yxv Duwb8sqDI8ug7lUVrPLGU6eLuAgFnvzZibR65ADR3ow0BhJV+8f/tDaFJ3kHg4f5x1/m 4Tl5OBussHlC/n00zgyIGBsYt3vi/HOz1BDnYMMfWG4E48bJmoEHnfws2wjeAG25n1lF dCoQ== X-Gm-Message-State: AOJu0YxpZsFYTtQuD+/MjlS+/X4jWPtibgh/iCUc3q7266Fs+XOXxUBV y5zXvsEsqbtGA1m8lG0S4hd7G4u+d9YNSVwtpVEr/TiWcQkkGVsvJyR5828XLuPBcvI7tfFOfBe zEsiQ+ZyuYVj6EDUm8NFJh0CIk6MUnJGURlM= X-Received: by 2002:a5d:508e:0:b0:317:73e3:cf41 with SMTP id a14-20020a5d508e000000b0031773e3cf41mr6416393wrt.1.1695028430605; Mon, 18 Sep 2023 02:13:50 -0700 (PDT) X-Received: by 2002:a5d:508e:0:b0:317:73e3:cf41 with SMTP id a14-20020a5d508e000000b0031773e3cf41mr6416363wrt.1.1695028430263; Mon, 18 Sep 2023 02:13:50 -0700 (PDT) Received: from [10.32.64.2] (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id b16-20020a05600010d000b0031aef72a021sm11830334wrx.86.2023.09.18.02.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 02:13:49 -0700 (PDT) Message-ID: <72a444cd42629f5bdd56647e7aa24588d6964bec.camel@redhat.com> Subject: Re: [PATCH v2 1/5] string.h: add array-wrappers for (v)memdup_user() From: Philipp Stanner To: Dan Carpenter Cc: Kees Cook , Andy Shevchenko , 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 Date: Mon, 18 Sep 2023 11:13:48 +0200 In-Reply-To: References: <93001a9f3f101be0f374080090f9c32df73ca773.1694202430.git.pstanner@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 02:15:52 -0700 (PDT) On Sat, 2023-09-16 at 17:32 +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) > > +{ > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0size_t nbytes; > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (unlikely(check_mul_overf= low(n, size, &nbytes))) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return ERR_PTR(-EOVERFLOW); >=20 > No need for an unlikely() because check_mul_overflow() already has > one > inside. ACK. I overlooked that as it was hidden in the callstack. > =C2=A0 I feel like -ENOMEM is more traditional but I doubt > anyone/userspace > cares. I agree with Andy here. We're not allocating, so -ENOMEM makes no sense IMO. P. >=20 > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return memdup_user(src, nbyt= es); > > +} >=20 > regards, > dan carpenter >=20