[uClibc-cvs] uClibc/libc/sysdeps/linux/common syscalls.c, 1.122, 1.123

Erik Andersen andersen at uclibc.org
Wed Dec 31 11:50:11 UTC 2003


Update of /var/cvs/uClibc/libc/sysdeps/linux/common
In directory nail:/tmp/cvs-serv15002

Modified Files:
	syscalls.c 
Log Message:
Add extra checks for sigprocmask and rt_sigprocmask syscalls.
The rt_sigprocmask syscall has broken error handling in 2.4.x
kernels, while the sigprocmask syscall appears to get things
right.  Regardless we should be extra careful, and add these
checks.


Index: syscalls.c
===================================================================
RCS file: /var/cvs/uClibc/libc/sysdeps/linux/common/syscalls.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- syscalls.c	22 Dec 2003 10:47:04 -0000	1.122
+++ syscalls.c	31 Dec 2003 11:50:08 -0000	1.123
@@ -1427,11 +1427,29 @@
 
 //#define __NR_sigprocmask      126
 #ifndef __NR_rt_sigprocmask
-#ifdef L_sigprocmask
+#ifdef L___syscall_sigprocmask
 #include <signal.h>
-#undef sigprocmask
-_syscall3(int, sigprocmask, int, how, const sigset_t *, set, 
+#define __NR___syscall_sigprocmask __NR_sigprocmask
+static inline
+_syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
 		sigset_t *, oldset);
+#undef sigprocmask
+int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
+{
+	if (set &&
+#if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
+	(((unsigned int) how) > 2)
+#else
+#warning "compile time assumption violated.. slow path..."
+	((how != SIG_BLOCK) && (how != SIG_UNBLOCK) && (how != SIG_SETMASK))
+#endif
+	   )
+	{
+		__set_errno (EINVAL);
+		return -1;
+	}
+	return(__syscall_sigprocmask(how, set, oldset));
+}
 #endif
 #endif
 
@@ -1942,7 +1960,19 @@
 
 int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) 
 {
-	  return __rt_sigprocmask(how, set, oldset, _NSIG/8);
+	if (set &&
+#if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
+			(((unsigned int) how) > 2)
+#else
+#warning "compile time assumption violated.. slow path..."
+			((how != SIG_BLOCK) && (how != SIG_UNBLOCK) && (how != SIG_SETMASK))
+#endif
+	   )
+	{
+		__set_errno (EINVAL);
+		return -1;
+	}
+	return __rt_sigprocmask(how, set, oldset, _NSIG/8);
 }
 #endif
 #endif




More information about the uClibc-cvs mailing list