Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6687333rwl; Tue, 4 Apr 2023 17:30:34 -0700 (PDT) X-Google-Smtp-Source: AKy350ab24OU+pir1VZ7RNypx/1KMZshxmF+0w+l1NPEVJev2XfqCmmYfQgVL1PQs19657yViR8f X-Received: by 2002:a17:906:585:b0:925:6bcb:4796 with SMTP id 5-20020a170906058500b009256bcb4796mr822544ejn.38.1680654633975; Tue, 04 Apr 2023 17:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680654633; cv=none; d=google.com; s=arc-20160816; b=Gm5if9jvLI0QOAt27dAcEC7J0bgYkPEePbROtJb1/kUAayr18CjmHM5KnjJASYA+27 QqBcvPFL0b4AxtLhIiSi0NTuG+MDMGNRTw4OhOhUXqbrncq4vmfTpbednZnaZvPeohhV YfScy2ZxwTixjRtoMBKfG97TgqRVfbnvpVz4FJfXdvtrDGOFXWZodfFhEieaEBa218K2 Kyua4Am3rEW3bFZypv2gja7Ou8ipQeMIBvmnN88WNbI7tKMf/RPTjhdRZdV53iz6AB+r IMnIk52+pE1yWMAOinhTTMW+ztC7kDGEAvQkf7ogLYpfa9g7NFlfrUGOdQ6y1fxXzjc5 WsdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=ocJqChMt1z19AkZ29xL82uUThwF2VFmVYjBYyFKJblg=; b=to3CYpHWCJsHzgTGxtmA86f4gvKvq3vBipMDKs1pKkUCL7UY+gSfJukScMlgC/eqr0 VC4hUeWTJdu5t7Ke+drWjEONIL7QKePRjmNCr5VIK/gpYuaN69sRdq2g7Z9nLSmVpHb6 GRcdHceUJzlcd2FTiwLfBOISVGRIUTk3pv2mjp8A63NXosNRPGs0CHk2KFTgk9mwIF1r YUPmf4CiG5pDVb9lZfcIQFyd29GwWJKr6qhGpm7qNqXumU9cuENJdBHnT4pvpx6No6di YRO5XBrAksEBMBSFhInXoGzGIbEXc/XVPTY8BsaJ3HGZ2a9cWZAxuGz352m5uvTi+78X dF9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joshtriplett.org header.s=fm1 header.b=ckHxW7Vz; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=S2opLDcE; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh33-20020a1709076ea100b00947b5e0ec15si869905ejc.110.2023.04.04.17.30.07; Tue, 04 Apr 2023 17:30:33 -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=@joshtriplett.org header.s=fm1 header.b=ckHxW7Vz; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=S2opLDcE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236551AbjDEAZv (ORCPT + 99 others); Tue, 4 Apr 2023 20:25:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236398AbjDEAZt (ORCPT ); Tue, 4 Apr 2023 20:25:49 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEEBB3C15 for ; Tue, 4 Apr 2023 17:25:48 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 251863200A74; Tue, 4 Apr 2023 20:25:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 04 Apr 2023 20:25:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= joshtriplett.org; h=cc:cc:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1680654347; x=1680740747; bh=ocJqChMt1z19AkZ29xL82uUThwF2VFmVYjB YyFKJblg=; b=ckHxW7VzB2DAZXXTWL1189IT1mChZ34BgPfx62Zjxlm+RnG13Jl M14Vb7/h8Cx4dO2vsLHyKg81y6UIA3W6gHhbgsht4o8yisWXiIfA7a8Q1sXfqkYr rzgLWTXePbT2yRWi8AeSHhVZQS1AU3KSi2NdvMte7/7Uq5/QWMB+CLyFdvNJ1elZ UNr32JuN9zr7jj+iupS7J0FdEyw8ZS08cWw/SwtCSYdFuNHr1jEhw23pAhUrBEI0 o/MCIsB/edQvxSuCXH/96N1s/tgCdaboPJ/BWsOttOsHz4MnViPzfYTnmiKeTDNP /1h9odl74Io4hF/UABoWkRYBABb6wyfDcjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1680654347; x=1680740747; bh=ocJqChMt1z19A kZ29xL82uUThwF2VFmVYjBYyFKJblg=; b=S2opLDcEfuJpnbyquL6GjRmvEyGHh AuRXqLMfiiqVoBZq44jcyRN62OijDqn29S4wlqt0SmHjPx8QYPiU6H9gL/LiLcqb wIg9MYKREDZ/0/v5CMJKr9iarnnYRbTrBU4iaZaNiqMZ1aXsrYFMlEK25dWuGXlB afxCDazZ/+vUsalQ2Jez9DOdOg27s699Y5WbldgF1LHccgpYPctUXZcQRRaDD1+E zedU2Z2Zjd8BdVGzpqJHwNzBNvD8gYbBrnSrg1+racs45CxuWKqC5N0RTjYg2nMc gpishJt1aPP7GIfqfe/ZzhcFO8yRpqxZleLkKQ02251Qu7E9u0V6/K5wA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdejtddgfedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehttd ertddttddvnecuhfhrohhmpeflohhshhcuvfhrihhplhgvthhtuceojhhoshhhsehjohhs hhhtrhhiphhlvghtthdrohhrgheqnecuggftrfgrthhtvghrnhepudeigeehieejuedvte dufeevtdejfeegueefgffhkefgleefteetledvtdfftefgnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhoshhhsehjohhshhhtrhhiphhlvg htthdrohhrgh X-ME-Proxy: Feedback-ID: i83e94755:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Apr 2023 20:25:45 -0400 (EDT) Date: Wed, 5 Apr 2023 09:25:43 +0900 From: Josh Triplett To: Andrew Morton Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] prctl: Add PR_GET_AUXV to copy auxv to userspace Message-ID: References: <20230404124355.3efa7a201d2aa9896dc6353e@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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, Apr 05, 2023 at 09:24:36AM +0900, Josh Triplett wrote: > On Tue, Apr 04, 2023 at 12:43:55PM -0700, Andrew Morton wrote: > > On Tue, 4 Apr 2023 21:31:48 +0900 Josh Triplett wrote: > > > --- a/kernel/sys.c > > > +++ b/kernel/sys.c > > > @@ -2377,6 +2377,16 @@ static inline int prctl_get_mdwe(unsigned long arg2, unsigned long arg3, > > > PR_MDWE_REFUSE_EXEC_GAIN : 0; > > > } > > > > > > +static int prctl_get_auxv(void __user *addr, unsigned long len) > > > +{ > > > + struct mm_struct *mm = current->mm; > > > + unsigned long size = min_t(unsigned long, sizeof(mm->saved_auxv), len); > > > + > > > + if (size && copy_to_user(addr, mm->saved_auxv, size)) > > > + return -EFAULT; > > > + return sizeof(mm->saved_auxv); > > > +} > > > > The type choices are unpleasing. Maybe make `len' a size_t and make > > the function return a size_t? That way prctl_get_auxv() will be much > > nicer, but the caller less so. > > It'd have to be an ssize_t return to support returning -EFAULT. Also, > sadly, size_t would still look just as bad, because > `sizeof(mm->saved_auxv)` doesn't have type size_t (at least according to > the error from the type-safe min macro). So this would still need a cast > or a `min_t`. > > But I'm happy to change the argument to size_t and the return value to > ssize_t, if you'd prefer. Will send v3 with that changed. That said, *all* the other helper functions here seem to return int...