[PATCH] nptl: Properly inline setgroups syscall [BZ #26248]

Florian Weimer fweimer@redhat.com
Thu Jul 16 12:03:12 GMT 2020


* H. J. Lu via Libc-alpha:

> 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.
>
> Add <setxid-internal.h> to define INTERNAL_SETXID_SYSCALL_NCS and use it,
> instead of INTERNAL_SYSCALL_NCS, for SETXID syscalls.  X32 override it
> with pointer type for setgroups.  A testcase is added and setgroups
> returned with EFAULT when running as root without the fix.

Isn't it sufficient to change the type of id to unsigned long int[3]?
The UID arguments are unsigned on the kernel side, so no sign extension
is required.

Thanks,
Florian



More information about the Libc-alpha mailing list