]> sourceware.org Git - glibc.git/commitdiff
Add a C wrapper for prctl [BZ #25896]
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 30 Apr 2020 17:42:43 +0000 (10:42 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 30 Apr 2020 17:42:43 +0000 (10:42 -0700)
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);

include/sys/prctl.h
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/prctl.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/syscalls.list

index 0920ed642b43bbc6b462e1d7a66ae59455c84bda..d33f3a290e77527a01bd393e3f3f5b169b7e8b78 100644 (file)
@@ -4,6 +4,7 @@
 # ifndef _ISOMAC
 
 extern int __prctl (int __option, ...);
+libc_hidden_proto (__prctl)
 
 # endif /* !_ISOMAC */
 #endif
index db78eeadd1e9d650389113f5d5f8c577875b9220..0326f92c404efbf050291fa9fac8513d6e18bb89 100644 (file)
@@ -59,7 +59,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
                   eventfd eventfd_read eventfd_write prlimit \
                   personality epoll_wait tee vmsplice splice \
                   open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \
-                  timerfd_gettime timerfd_settime \
+                  timerfd_gettime timerfd_settime 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 (file)
index 0000000..d5725f1
--- /dev/null
@@ -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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include <stdarg.h>
+#include <sys/prctl.h>
+
+/* 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)
index ced77d49fab258787769a95806cccc70273f5171..1d8893d1b8b32c61923ca6a0272696ca3b3a2a89 100644 (file)
@@ -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
This page took 0.047462 seconds and 5 git commands to generate.