about summary refs log tree commit diff
path: root/nptl/nptl-init.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2014-03-24 15:24:02 +0100
committerFlorian Weimer <fweimer@redhat.com>2014-04-01 10:29:56 +0200
commit13f7fe35ae2b0ea55dc4b9628763aafdc8bdc30c (patch)
tree795c9d70e0d45f280c06e36e89d350dd3fbf8161 /nptl/nptl-init.c
parentc859b32e9d76afe8a3f20bb9528961a573c06937 (diff)
downloadglibc-13f7fe35ae2b0ea55dc4b9628763aafdc8bdc30c.tar.gz
glibc-13f7fe35ae2b0ea55dc4b9628763aafdc8bdc30c.tar.xz
glibc-13f7fe35ae2b0ea55dc4b9628763aafdc8bdc30c.zip
Check for syscall error in the SETXID implementation in NPTL (bug 13347).
At this point, we can only abort the process because we have already
switched credentials on other threads.  Returning an error would still
leave the process in an inconsistent state.

The new xtest needs root privileges to run.
Diffstat (limited to 'nptl/nptl-init.c')
-rw-r--r--nptl/nptl-init.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 794156ba8e..2796dc5182 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -232,6 +232,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
   /* Determine the process ID.  It might be negative if the thread is
      in the middle of a fork() call.  */
   pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+  int result;
   if (__glibc_unlikely (pid < 0))
     pid = -pid;
 
@@ -245,8 +246,12 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
     return;
 
   INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL_NCS (__xidcmd->syscall_no, err, 3, __xidcmd->id[0],
-			__xidcmd->id[1], __xidcmd->id[2]);
+  result = INTERNAL_SYSCALL_NCS (__xidcmd->syscall_no, err, 3, __xidcmd->id[0],
+				 __xidcmd->id[1], __xidcmd->id[2]);
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+    /* Safety check.  This should never happen if the setxid system
+       calls are only ever called through their glibc wrappers.  */
+    abort ();
 
   /* Reset the SETXID flag.  */
   struct pthread *self = THREAD_SELF;