[PATCH] nptl: Zero-extend arguments to SETXID syscalls [BZ #26248]
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 16 Jul 2020 10:37:10 +0000 (03:37 -0700)
committerAurelien Jarno <aurel32@debian.org>
Wed, 22 Jul 2020 22:26:24 +0000 (23:26 +0100)
commit452e85b68cbd3266ab9d10e21a6c6fbe7091cfe0
tree6815e39f6a0dcaca7ecde77c8879c4ca97aaaf43
parentab6a9141a9f0c75632df6cb18821c79d603e607b
[PATCH] 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.

Gbp-Pq: Topic x32
Gbp-Pq: Name submitted-fix-nptl-setgroups-x32.diff
nptl/descr.h