From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 26 04:02:59 2021 Received: (at submit) by debbugs.gnu.org; 26 Dec 2021 09:02:59 +0000 Received: from localhost ([127.0.0.1]:40223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1PQg-0001kT-St for submit@debbugs.gnu.org; Sun, 26 Dec 2021 04:02:59 -0500 Received: from lists.gnu.org ([209.51.188.17]:50824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1LvB-0003JN-Rk for submit@debbugs.gnu.org; Sun, 26 Dec 2021 00:18:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1LvB-00058x-3d for bug-coreutils@gnu.org; Sun, 26 Dec 2021 00:18:13 -0500 Received: from [2a00:1450:4864:20::12a] (port=39884 helo=mail-lf1-x12a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n1Lv9-0006p6-EG for bug-coreutils@gnu.org; Sun, 26 Dec 2021 00:18:12 -0500 Received: by mail-lf1-x12a.google.com with SMTP id bp20so27514042lfb.6 for ; Sat, 25 Dec 2021 21:18:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WQvQvAJNoLBF8Y9e1QznuNMIjzQ9WLhV02os7k5QNiU=; b=UI7gcK/z9R7Hg0tX5hkLL1Ah6ATTuuy271QZZwT+A3yWqIFLSwPfDu/cKFLws8HIzl pjtqpFY8xkrPdloCDjQy23zLKx9QFaEntu8xI7/eWGE4Y/5BtFN5VYKGTSVC2ZwezLqw +CXUs0DLuXQuUFGVQ40oSm6v2fjSeXu6aQsm8T0RmDn8KFrGKZniPOqEvcq9dAkyYpVO wE+3PpnscYchDsmphbS37qAEfrwpWMbs64uyHW8eHyR5HsCFj6oQ2BHTr8kK6HIjamn2 5aHodskME+33vp1w183L0L/CB8fXD3eCJxg14Ii6hSAHwLCOz2Sk0QvJgPgJpCJ0lv6h 0w2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WQvQvAJNoLBF8Y9e1QznuNMIjzQ9WLhV02os7k5QNiU=; b=fNpoIvNcwXIREQierB0u+UfUBGR0LcIKiSCBkeAXVrSjB1Z35bAknVoTHHWKWFDy2f i5gpAF90eu+lGq8sSTAqbhDbweBknqkgnBwecw+hUz65SjYCh7Q594XooQgczsrjlwdU vgjtJ3+Vr4s4c7hOqs8Z/apOTVQRCWKAbPoMvNlb9TvcEb/jfWFihWMA8X+b4cnpxIvF HxgdHV120L1prflCiTZtPQhPKi/MXY5Q/xYdaOtHx6/p7O6+u6wujag01RyuMqoyMAOq Z2o0Jzj1twAulBHwpGN/nSo2pXgGslC2OZ1ceXuyQRNViJHPVdXYmXczyN4EBWLCmatR LJDA== X-Gm-Message-State: AOAM531651Zns6UzHnAPQudd9jsIGYWjn6DhxvnFxKV3NYYBCRdBAMPI kkFcHv/DLlNKtKHVuMP+wKss59CitAg= X-Google-Smtp-Source: ABdhPJx9u62BbNmiV+BY+XnPyoHAK8kWH6/vibmI57OtWFsXo8G61ysayYcBZ2S++jesyOemeHUaHg== X-Received: by 2002:a05:6512:2626:: with SMTP id bt38mr10940973lfb.255.1640495888627; Sat, 25 Dec 2021 21:18:08 -0800 (PST) Received: from octofox.metropolis ([5.18.187.11]) by smtp.gmail.com with ESMTPSA id c13sm1275640lfb.94.2021.12.25.21.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Dec 2021 21:18:07 -0800 (PST) From: Max Filippov To: bug-coreutils@gnu.org Subject: [PATCH] maint: fix prctl arguments Date: Sat, 25 Dec 2021 21:17:44 -0800 Message-Id: <20211226051744.7771-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12a (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=jcmvbkbc@gmail.com; helo=mail-lf1-x12a.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FROM_LOCAL_NOVOWEL=0.5, HK_RANDOM_ENVFROM=0.639, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When configured with --enable-single-binary tools issue incorrect prctl: prctl(PR_SET_KEEPCAPS, 1071091381) = -1 EINVAL (Invalid argument) PR_SET_MM_ARG_START is not a prctl 'option' parameter, it's 'arg2' parameter for the option PR_SET_MM. It also has to have 'arg4' and 'arg5' set to 0 explicitly, otherwise the kernel also returns -EIN [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 HK_RANDOM_FROM From username looks random 0.5 FROM_LOCAL_NOVOWEL From: localpart has series of non-vowel letters 0.0 HK_RANDOM_ENVFROM Envelope sender username looks random -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (jcmvbkbc[at]gmail.com) 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.51.188.17 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 1.3 SPOOFED_FREEMAIL No description available. 0.9 SPOOF_GMAIL_MID From Gmail but it doesn't seem to be... X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 26 Dec 2021 04:02:58 -0500 Cc: Max Filippov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) When configured with --enable-single-binary tools issue incorrect prctl: prctl(PR_SET_KEEPCAPS, 1071091381) = -1 EINVAL (Invalid argument) PR_SET_MM_ARG_START is not a prctl 'option' parameter, it's 'arg2' parameter for the option PR_SET_MM. It also has to have 'arg4' and 'arg5' set to 0 explicitly, otherwise the kernel also returns -EINVAL. * src/coreutils.c (launch_program): Fix prctl arguments. --- src/coreutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreutils.c b/src/coreutils.c index 6db5a8f05ce3..d8f6e97a6d2f 100644 --- a/src/coreutils.c +++ b/src/coreutils.c @@ -121,7 +121,7 @@ launch_program (char const *prog_name, int prog_argc, char **prog_argv) #if HAVE_PRCTL && defined PR_SET_MM_ARG_START /* Shift the beginning of the command line to prog_argv[0] (if set) so /proc/pid/cmdline reflects the right value. */ - prctl (PR_SET_MM_ARG_START, prog_argv[0]); + prctl (PR_SET_MM, PR_SET_MM_ARG_START, prog_argv[0], 0, 0); #endif exit (prog_main (prog_argc, prog_argv)); -- 2.20.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 26 12:26:30 2021 Received: (at 52800-done) by debbugs.gnu.org; 26 Dec 2021 17:26:30 +0000 Received: from localhost ([127.0.0.1]:41447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1XHx-0004H5-WA for submit@debbugs.gnu.org; Sun, 26 Dec 2021 12:26:30 -0500 Received: from mail-wm1-f54.google.com ([209.85.128.54]:38755) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1XHw-0004Gs-Q8 for 52800-done@debbugs.gnu.org; Sun, 26 Dec 2021 12:26:29 -0500 Received: by mail-wm1-f54.google.com with SMTP id p1-20020a1c7401000000b00345c2d068bdso7323575wmc.3 for <52800-done@debbugs.gnu.org>; Sun, 26 Dec 2021 09:26:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=J8Y4kNgUJbHlMFBf7f75hDE1Uvgr2pE3/+j3lrJyUgY=; b=qrF3x/GxGYnXWRjEFqiSIwWOuwGWU+qGcPJu2Ix+zVSnnyixj4tDs8GLAJ7zL878Wi NbLo0UR5/HuTYrpcH2qatH3+KdKAsKgeAJ3lzfv0NEcwjFYeONuAQw5MjV/NefQodXm7 g7MJYuvCHNK8RVKs9Cd3BC65RpnokTwahWdEc43bCSFKS2GTlzBfV2B2jsHmQvnGS/id WVFMc09acMz+FmB9Hv2LlWoqUX5QNjlpnhX37RcA6ySoyXNUhVa80kdCZw1O5rtmBJ8g Yb0+Dwa47Hxh0y33vG6nNg2HoiPbIZbCJn1V0tGzTR39RPAGQ1AMmM0We6UC74TffWyV 16ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=J8Y4kNgUJbHlMFBf7f75hDE1Uvgr2pE3/+j3lrJyUgY=; b=sTOg7uFPqnZUWpd+za2PJoyeMjTgXICYx/Ue+CtifY0FHw6JxaxAN4R96Rj0n2Lrr2 5zrP6pfe2s09t9zHAoU1I6az30bTINdIYrh4F++FkMqGHwMQvdrmV05M/WQ/0gFnGbYc g1++VdU1CKb1yXeEC2Irzqm+F+Vg8gl1NQIgKv+DimyFR6UFfWe4MraE4ss5ehwkuCTd 9cwIvtPb8n1xocJcoAGJXiA4z8mD0bqXrcN0pxPJa3r9c/j133rwBJQC+Txm6rAsORrW 6GPUL+C0SDnberZitzdM4+QPLlwbnCX+bHgFnqkg4KxVEcw1gC1WcnOgizwXiJiO4las xMLA== X-Gm-Message-State: AOAM53300X+h11eONQshXaqBS/G69skx2a9YrUqmZH570Q3+Qbynrw1M 1C4fmAYpDvRQ93Uz2OdjFwc= X-Google-Smtp-Source: ABdhPJz8/V0/PFjQjzJFQWQfC4mwbVjXxxvURQEvOeyuziJtnfZwIpr6rxi4m7t/WyoblNPsV7tl7A== X-Received: by 2002:a05:600c:34c4:: with SMTP id d4mr10940199wmq.53.1640539582951; Sun, 26 Dec 2021 09:26:22 -0800 (PST) Received: from [192.168.1.9] (86-40-129-104-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.40.129.104]) by smtp.googlemail.com with ESMTPSA id o15sm4982372wri.106.2021.12.26.09.26.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Dec 2021 09:26:22 -0800 (PST) Message-ID: Date: Sun, 26 Dec 2021 17:26:20 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Thunderbird/95.0 Subject: Re: bug#52800: [PATCH] maint: fix prctl arguments Content-Language: en-US To: Max Filippov , 52800-done@debbugs.gnu.org References: <20211226051744.7771-1-jcmvbkbc@gmail.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= In-Reply-To: <20211226051744.7771-1-jcmvbkbc@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 52800-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 26/12/2021 05:17, Max Filippov wrote: > When configured with --enable-single-binary tools issue incorrect prctl: > > prctl(PR_SET_KEEPCAPS, 1071091381) = -1 EINVAL (Invalid argument) > > PR_SET_MM_ARG_START is not a prctl 'option' parameter, it's 'arg2' > parameter for the option PR_SET_MM. It also has to have 'arg4' and > 'arg5' set to 0 explicitly, otherwise the kernel also returns -EINVAL. > > * src/coreutils.c (launch_program): Fix prctl arguments. > --- > src/coreutils.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/coreutils.c b/src/coreutils.c > index 6db5a8f05ce3..d8f6e97a6d2f 100644 > --- a/src/coreutils.c > +++ b/src/coreutils.c > @@ -121,7 +121,7 @@ launch_program (char const *prog_name, int prog_argc, char **prog_argv) > #if HAVE_PRCTL && defined PR_SET_MM_ARG_START > /* Shift the beginning of the command line to prog_argv[0] (if set) so > /proc/pid/cmdline reflects the right value. */ > - prctl (PR_SET_MM_ARG_START, prog_argv[0]); > + prctl (PR_SET_MM, PR_SET_MM_ARG_START, prog_argv[0], 0, 0); > #endif > > exit (prog_main (prog_argc, prog_argv)); Nice one. This functionality allows programs like ps to attribute to more specific "utilities", rather than the general "coreutils" binary. However this is only available with CAP_SYS_RESOURCE or root. Note CAP_SYS_RESOURCE wouldn't be appropriate to set on the coreutils binary in general. I confirmed your patch is effective for coreutils invoked by root with: $ src/sleep 5 & { sleep 1; tr '\0' '\n' < /proc/$!/cmdline; } /home/padraig/git/coreutils/src/coreutils --coreutils-prog-shebang=sleep src/sleep 5 # src/sleep 5 & { sleep 1; tr '\0' '\n' < /proc/$!/cmdline; } sleep 5 I'll apply later (with some adjustments to NEWS) Marking this as done. thanks! Pádraig From unknown Wed Jun 18 00:28:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 24 Jan 2022 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator