From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by sourceware.org (Postfix) with ESMTPS id 9B0143898538 for ; Thu, 30 Apr 2020 19:34:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9B0143898538 Received: by mail-pf1-x441.google.com with SMTP id x15so364644pfa.1 for ; Thu, 30 Apr 2020 12:34:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fri3oNnt64aHf4r+DSS+PaIhDmSuQw6i/Gs5zSfrWJ4=; b=tx4dNIznT/jpULRUsMouGONuEAOZj6bHykTvnlqfni+VaLTcYcdgBqwpRAA3yFkoDa epa1HRKgoEgJbWrZtrTqF2/e52Rx0FjJKbfwCZVdYyldbQYZecHZYA7kZ7yDGzv6ie6A LaalrbItAwSzkGta2U0TAgjI0/+172FBUhEecq9u2ys8haGyFN2phsseo34vbMpVrbVj Tykx66tAXBoO1+tpidJJ+iL+Fv412DDOZhJZDG+ai1htmNH2k2f2QeEIeX0J6GTtMAV1 Q9es1oh2rn83KpG5ITbVrw6hnfClcsLiyivwtI8G8lSpgPbi0uV5XMpCnp8VCH7/DaeE jKFA== X-Gm-Message-State: AGi0PuYlD/sGcQ4onwT7okPYqi0HPR0takTXBrBx+zFU/DmSBZe2+dEO l4IQ70+qwlVpQoGLhbeKgXLfEIaD X-Google-Smtp-Source: APiQypJsxAp4pvuw4rcRYAfVQ1r71P4+kMtNxNt6MH0dK+1epSA29MKUDomGpXD+s8wK5G5y7YSY7g== X-Received: by 2002:a63:1b18:: with SMTP id b24mr535511pgb.90.1588275267493; Thu, 30 Apr 2020 12:34:27 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id y29sm481877pfq.162.2020.04.30.12.34.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 12:34:27 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 24E1D1A0121 for ; Thu, 30 Apr 2020 12:34:24 -0700 (PDT) From: "H.J. Lu" To: libc-stable@sourceware.org Subject: [2.31/2.30] [PATCH 6/6] Add a C wrapper for prctl [BZ #25896] Date: Thu, 30 Apr 2020 12:34:23 -0700 Message-Id: <20200430193423.807713-7-hjl.tools@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200430193423.807713-1-hjl.tools@gmail.com> References: <20200430193423.807713-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2020 19:34:37 -0000 Add a C wrapper to pass arguments in /* Control process execution. */ extern int prctl (int __option, ...) __THROW; to prctl syscall: extern int prctl (int, unsigned long int, unsigned long int, unsigned long int, unsigned long int); (cherry picked from commit ff026950e280bc3e9487b41b460fb31bc5b57721) --- include/sys/prctl.h | 1 + sysdeps/unix/sysv/linux/Makefile | 1 + sysdeps/unix/sysv/linux/prctl.c | 42 +++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/syscalls.list | 1 - 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/prctl.c diff --git a/include/sys/prctl.h b/include/sys/prctl.h index 0920ed642b..d33f3a290e 100644 --- a/include/sys/prctl.h +++ b/include/sys/prctl.h @@ -4,6 +4,7 @@ # ifndef _ISOMAC extern int __prctl (int __option, ...); +libc_hidden_proto (__prctl) # endif /* !_ISOMAC */ #endif diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 62f1642732..5fbde369c3 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -61,6 +61,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead \ eventfd eventfd_read eventfd_write prlimit \ personality epoll_wait tee vmsplice splice \ open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \ + prctl \ process_vm_readv process_vm_writev CFLAGS-gethostid.c = -fexceptions diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c new file mode 100644 index 0000000000..d5725f14cf --- /dev/null +++ b/sysdeps/unix/sysv/linux/prctl.c @@ -0,0 +1,42 @@ +/* prctl - Linux specific syscall. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +/* Unconditionally read all potential arguments. This may pass + garbage values to the kernel, but avoids the need for teaching + glibc the argument counts of individual options (including ones + that are added to the kernel in the future). */ + +int +__prctl (int option, ...) +{ + va_list arg; + va_start (arg, option); + unsigned long int arg2 = va_arg (arg, unsigned long int); + unsigned long int arg3 = va_arg (arg, unsigned long int); + unsigned long int arg4 = va_arg (arg, unsigned long int); + unsigned long int arg5 = va_arg (arg, unsigned long int); + va_end (arg); + return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5); +} + +libc_hidden_def (__prctl) +weak_alias (__prctl, prctl) diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 5bb66d5481..52e6dafc86 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -43,7 +43,6 @@ nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC pipe - pipe i:f __pipe pipe pipe2 - pipe2 i:fi __pipe2 pipe2 pivot_root EXTRA pivot_root i:ss pivot_root -prctl EXTRA prctl i:iiiii __prctl prctl query_module EXTRA query_module i:sipip __compat_query_module query_module@GLIBC_2.0:GLIBC_2.23 quotactl EXTRA quotactl i:isip quotactl remap_file_pages - remap_file_pages i:pUiUi __remap_file_pages remap_file_pages -- 2.26.2