Просмотр исходного кода

csky: make __kernel_uid_t/__kernel_gid_t 32-bit

csky is an asm-generic architecture: it has only __NR_setresuid (no
__NR_setresuid32) and 32-bit uids.  But bits/kernel_types.h declared
__kernel_uid_t/__kernel_gid_t as unsigned short, so setresuid.c took the
16-bit "#elif __NR_setresuid" path and passed the syscall arguments as
16-bit.  The (uid_t)-1 "do not change" sentinel was thus truncated to
0xffff (65535), so setresuid(-1, uid, -1) -- as used by seteuid() --
clobbered the real and saved uid to 65535, making it impossible to
return to uid 0 (seteuid(0) -> EPERM).  This broke every set*id(-1, ...)
call on csky.

Use unsigned int, matching the other asm-generic targets (riscv, nios2,
arc, xtensa, aarch64).

Verified with test/nptl/tst-mqueue9 under qemu-system-cskyv2.

Signed-off-by: Ramin Moussavi <ramin.moussavi@yacoub.de>
Ramin Moussavi 1 неделя назад
Родитель
Сommit
859a6f03b8
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      libc/sysdeps/linux/csky/bits/kernel_types.h

+ 2 - 2
libc/sysdeps/linux/csky/bits/kernel_types.h

@@ -22,8 +22,8 @@ typedef unsigned short	__kernel_nlink_t;
 typedef long		__kernel_off_t;
 typedef int		__kernel_pid_t;
 typedef unsigned short	__kernel_ipc_pid_t;
-typedef unsigned short	__kernel_uid_t;
-typedef unsigned short	__kernel_gid_t;
+typedef unsigned int	__kernel_uid_t;
+typedef unsigned int	__kernel_gid_t;
 typedef unsigned int	__kernel_size_t;
 typedef int		__kernel_ssize_t;
 typedef int		__kernel_ptrdiff_t;