summary refs log tree commit diff
path: root/nptl/descr.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-07-16 03:37:10 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-07-27 12:32:41 -0700
commit0ad926f34937f7b4843a8b49e5d93199601fe324 (patch)
treeca8a5ee934163ebaff49497afd15513bf6cc8fda /nptl/descr.h
parentb51c1500e02cec3a61c385d5aa919287f32bbd58 (diff)
downloadglibc-0ad926f34937f7b4843a8b49e5d93199601fe324.tar.gz
glibc-0ad926f34937f7b4843a8b49e5d93199601fe324.tar.xz
glibc-0ad926f34937f7b4843a8b49e5d93199601fe324.zip
nptl: Zero-extend arguments to SETXID syscalls [BZ #26248]
nptl has

/* Opcodes and data types for communication with the signal handler to
   change user/group IDs.  */
struct xid_command
{
  int syscall_no;
  long int id[3];
  volatile int cntr;
  volatile int error;
};

 /* This must be last, otherwise the current thread might not have
     permissions to send SIGSETXID syscall to the other threads.  */
  result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, 3,
                                 cmdp->id[0], cmdp->id[1], cmdp->id[2]);

But the second argument of setgroups syscal is a pointer:

       int setgroups (size_t size, const gid_t *list);

But on x32, pointers passed to syscall must have pointer type so that
they will be zero-extended.  The kernel XID arguments are unsigned and
do not require sign extension.  Change xid_command to

struct xid_command
{
  int syscall_no;
  unsigned long int id[3];
  volatile int cntr;
  volatile int error;
};

so that all arguments are zero-extended.  A testcase is added for x32 and
setgroups returned with EFAULT when running as root without the fix.
Diffstat (limited to 'nptl/descr.h')
-rw-r--r--nptl/descr.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/nptl/descr.h b/nptl/descr.h
index 6a509b6725..d8343ff9a1 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -95,7 +95,13 @@ struct pthread_unwind_buf
 struct xid_command
 {
   int syscall_no;
-  long int id[3];
+  /* Enforce zero-extension for the pointer argument in
+
+     int setgroups (size_t size, const gid_t *list);
+
+     The kernel XID arguments are unsigned and do not require sign
+     extension.  */
+  unsigned long int id[3];
   volatile int cntr;
   volatile int error; /* -1: no call yet, 0: success seen, >0: error seen.  */
 };