Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1940661rdb; Tue, 5 Sep 2023 09:21:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEm2cbvc8f6S136L8qBf6cfqLUM5kzQFjHaGN6J980wkh6yXKSHrUlenfvsGcKVxsWKf768 X-Received: by 2002:a17:907:7f09:b0:9a1:8993:9532 with SMTP id qf9-20020a1709077f0900b009a189939532mr306303ejc.30.1693930873188; Tue, 05 Sep 2023 09:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693930873; cv=none; d=google.com; s=arc-20160816; b=jHi3gIG3jyKC9dKCxQkucKnkbeMNQZfDyP21sr11TI/0JSI4OrB07MMVT1CIbtNt5R WT0/xGkgVBaBkbnW4sQ7kg0v+i3v8PQDGBp6SEdFZcA3aaZ2fZmmIII0nWfOHu7zeZCk QDe1Jfn9ymE9d0WTGuMEpQTQYLo/N8nnRkdBppnwGmh5NLNx6fmoRIH9+tLZSeQII2MA 0o3FdelcZXjAkxCoMSIEWOF5AA+3qOsMR93OKRC2Ehi0BpOCtgazg+qI5ovY8KKK1Gj4 +Zqlvp2XEkdewwExEbZhM5YnNYX1AjA3iB65UfL5ymFOTvV+7Z86o9LvSgdbUweljBnF CIxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=+WCBkbdNR2D/dn3x6jAE+/xbR9io7eSmxn1U8tK6k34=; fh=hvGXvdbNrWbW0t1byaDH60gvk2KaAPppaBH747QRFnQ=; b=OfXaRvqDdz0QUy0jJqFMOnxIqtuwMKTLnUfH9LTFKmvnwEQqf6URoeWlLMQwJhZQem ptbwMobUEZVqbf6jUgUrp455tyJfPoKZWvqLF/tpdun/gahLfJujsck+6Q/wn3cqZzuU bpofGTMF4JbhFzLH1H1OnzjGmolNsiYR1bOq4/WQbbFOBz6Y/Hq+JQQt1v3NrRsVE8Bs CgbOihGBUb0zKqwrHkh34u1QWJOqxvRyKzq4iEdoO47xUW2cp+Hef7pzZ/k/QpcFKF46 0J88iHsN0gL2IlnIFSKj6E1+4DkZv5lfXD6ZjwyzUTxUJ4R/QL6RX+iXChxSBtNLMeEr 7TeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gQeykQMy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oq25-20020a170906cc9900b0098882e012dasi7186577ejb.443.2023.09.05.09.21.08; Tue, 05 Sep 2023 09:21:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gQeykQMy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242483AbjHaI74 (ORCPT + 8 others); Thu, 31 Aug 2023 04:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232299AbjHaI7z (ORCPT ); Thu, 31 Aug 2023 04:59:55 -0400 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B98DCF4; Thu, 31 Aug 2023 01:59:51 -0700 (PDT) Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5738cb00eebso369873eaf.2; Thu, 31 Aug 2023 01:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693472391; x=1694077191; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+WCBkbdNR2D/dn3x6jAE+/xbR9io7eSmxn1U8tK6k34=; b=gQeykQMyJnheAFbYczk2x2ut5YhnhXbdvpahC++wz4TAbz8U5YS30AG/TcIxhfj7eQ iGjofMYpui57B4LmjARvn0Js7dg05Z8r25tqkGnJE1EOaYW8e3848R9sbJ48hHZmCDY7 dfkXE/cKQ4lluKAteUYoMDfRPlsrFthMJFkEc0liyD1MIDpcY40vLeDbRsznkDb5eg4p o9WEQWVfH9W+Kef8YapnNuIKTKm1MERUp/mR8EZYAsxdkiN29weFsPjt+2LGPESqSMtE uXFZ8/6XUxsVcEKGdw/NgxMpnzOWl5Q8vQ9p4Nhr0UKLSE8JPaRX/gd5wGFXAtczGt+c ztag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693472391; x=1694077191; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+WCBkbdNR2D/dn3x6jAE+/xbR9io7eSmxn1U8tK6k34=; b=dq1GKHGczW1yRECkE6cewtYiZZKBEeJLwh21geKQSG/xwBAbikOr41JIaXa8Tow3ug Vvio88vwA4eABjtcfxwV0pKMS1GoiCjk8sIoCz56j9Zef9yZsoH7L07d3vhMFzdbp0bt WXPOXvGa1DZ+42iVLCJZTQ5kUzCgESP1szIXd+IN5K9klcvAa/K2U3PEhn8A+ZLsJZms 5bCMvyDbeTUrwbwr8b/LQCPP+Rgwinh2QPbdU6QMTVKDoF/Iccp9UOrU6UN68jgrTptg LFEtKX5LXrcKa2Xz7L2/h3BPUOYyrFMCSc3iYVWgyTqqDgK8O1OGmzpl5Mpime4vc7Kf XiwQ== X-Gm-Message-State: AOJu0YykxKGiAMoEbqu7pqngIViVUrlphFACN+goC2nPAlQ5VMqaGI94 OtBxzDRz6jAKCsstWIQ+8ArdxX69HRFA1D6YKqTubU4DH1o= X-Received: by 2002:a4a:2a52:0:b0:573:3711:51c4 with SMTP id x18-20020a4a2a52000000b00573371151c4mr4288732oox.8.1693472390851; Thu, 31 Aug 2023 01:59:50 -0700 (PDT) MIME-Version: 1.0 References: <46f667e154393a930a97d2218d8e90286d93a062.1693386602.git.pstanner@redhat.com> <721a70c347d82931d12e5b75b19d132f82ee5ed2.camel@redhat.com> In-Reply-To: From: Andy Shevchenko Date: Thu, 31 Aug 2023 11:59:14 +0300 Message-ID: Subject: Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user() To: pstanner@redhat.com 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Wed, Aug 30, 2023 at 10:15=E2=80=AFPM wrote: > On Wed, 2023-08-30 at 17:29 +0300, Andy Shevchenko wrote: > > On Wed, Aug 30, 2023 at 5:19=E2=80=AFPM wrote: > > > On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > > > > On Wed, Aug 30, 2023 at 4:46=E2=80=AFPM Philipp Stanner > > > > > > > > wrote: ... > > > > > #include /* for size_t */ > > > > > #include /* for NULL */ > > > > > #include /* for E2BIG */ > > > > > +#include /* for check_mul_overflow() */ > > > > > +#include /* for ERR_PTR() */ > > > > > > > > Can we preserve order (to some extent)? > > > > > > Sure. I just put it there so the comments build a congruent block. > > > Which order would you prefer? > > > > Alphabetical. > > > > compiler.h > > err.h > > overflow.h > > ...the rest that is a bit unordered... > > > > > > > #include > > > > > #include > > I mean I could include my own in a sorted manner =E2=80=93 but the existi= ng > ones are not sorted: I know, that's why I put "(to some extent)" in my initial comment. > We could sort them all, but I'd prefer to do that in a separate patch > so that this commit does not make the impression of doing anything else > than including the two new headers But you can do your stuff first with better ordering than you proposed initially, so there will be less churn for any additional change (either that simply unifies the thing or something else). > Such a separate patch could also unify the docstring style, see below Sure, patches are welcome! > > > > > +/** > > > > > + * memdup_array_user - duplicate array from user space > > > > > > > > > + * > > > > > > > > Do we need this blank line? > > > > > > I more or less directly copied the docstring format from the > > > original > > > functions (v)memdup_user() in mm/util.c > > > I guess this is common style? > > > > I think it's not. But you may grep kernel source tree and tell which > > one occurs more often with or without this (unneeded) blank line. > > > It seems to be very much mixed. string.h itself is mixed. > When you look at the bottom of string.h, you'll find functions such as > kbasename() that have the extra line. > > That's not really a super decisive point for me, though. We can remove > the line I guess I think the less LoCs the better generally speaking. So, if we don't need that line and it doesn't make the readability worse, why to keep it? > > > > > + * @src: source address in user space > > > > > + * @n: number of array members to copy > > > > > + * @size: size of one array member > > > > > + * > > > > > + * Return: an ERR_PTR() on failure. Result is physically > > > > > + * contiguous, to be freed by kfree(). > > > > > + */ -- With Best Regards, Andy Shevchenko