Subject: [PATCH] maint: fix prctl arguments
From: Max Filippov <[email-masked]>
To: [email-masked]
Cc: Max Filippov <[email-masked]>
Date: Sat, 25 Dec 2021 21:17:44 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

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