Hi all,

I'd like some feedback on the attached patch. The one I've attached now
will individually handle the prctl calls which uses arg2 and those who
do not. Checked up against Linux v2.6.27.

The solution is bad since it is locked against those prctl calls
available for a given kernel version. But there is (AFAIK) no way
of detecting the number of arguments given to prctl.

The way uClibc does it today is wrong, and does not work on AVR32
architecture.

For the record, prctl uses only arg2 at most, and there are some calls
which does not use arguments (see list in patch).

-- 
Best regards,
Hans-Christian Egtvedt
--- a/libc/sysdeps/linux/common/prctl.c
+++ b/libc/sysdeps/linux/common/prctl.c
@@ -8,10 +8,29 @@
  */
 
 #include <sys/syscall.h>
+#include <sys/prctl.h>
 #include <stdarg.h>
-/* psm: including sys/prctl.h would depend on kernel headers */
 
 #ifdef __NR_prctl
-extern int prctl (int, long, long, long, long);
-_syscall5(int, prctl, int, option, long, arg2, long, arg3, long, arg4, long, arg5)
+#define __NR___syscall_prctl	__NR_prctl
+static inline _syscall5(int, __syscall_prctl, int, option, long, arg2, long, arg3, long,
+		arg4, long, arg5);
+
+int prctl(int option, ...) {
+	long arg2 = 0;
+	va_list ap;
+
+	va_start(ap, option);
+
+	if (option != PR_GET_DUMPABLE
+			&& option != PR_GET_TIMING
+			&& option != PR_GET_SECCOMP
+			&& option != PR_GET_SECUREBITS
+			&& option != PR_GET_KEEPCAPS)
+		arg2 = va_arg(ap, long);
+
+	va_end(ap);
+
+	return __syscall_prctl(option, arg2, 0, 0, 0);
+}
 #endif
_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to