Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] compat: be more consistent about [ug]id_t

When I first wrote the compat layer patches, I was somewhat cavalier about
the definition of compat_uid_t and compat_gid_t (or maybe I just
misunderstood :-)). This patch makes the compat types much more consistent
with the types we are being compatible with and hopefully will fix a few
bugs along the way.

compat type type in compat arch
__compat_[ug]id_t __kernel_[ug]id_t
__compat_[ug]id32_t __kernel_[ug]id32_t
compat_[ug]id_t [ug]id_t

The difference is that compat_uid_t is always 32 bits (for the archs we
care about) but __compat_uid_t may be 16 bits on some.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Stephen Rothwell and committed by
Linus Torvalds
202e5979 8dbfc5cf

+87 -76
+8 -8
arch/mips/kernel/linux32.c
··· 546 546 struct ipc_perm32 547 547 { 548 548 key_t key; 549 - compat_uid_t uid; 550 - compat_gid_t gid; 551 - compat_uid_t cuid; 552 - compat_gid_t cgid; 549 + __compat_uid_t uid; 550 + __compat_gid_t gid; 551 + __compat_uid_t cuid; 552 + __compat_gid_t cgid; 553 553 compat_mode_t mode; 554 554 unsigned short seq; 555 555 }; 556 556 557 557 struct ipc64_perm32 { 558 558 key_t key; 559 - compat_uid_t uid; 560 - compat_gid_t gid; 561 - compat_uid_t cuid; 562 - compat_gid_t cgid; 559 + __compat_uid_t uid; 560 + __compat_gid_t gid; 561 + __compat_uid_t cuid; 562 + __compat_gid_t cgid; 563 563 compat_mode_t mode; 564 564 unsigned short seq; 565 565 unsigned short __pad1;
+8 -8
fs/compat.c
··· 720 720 struct compat_ncp_mount_data { 721 721 compat_int_t version; 722 722 compat_uint_t ncp_fd; 723 - compat_uid_t mounted_uid; 723 + __compat_uid_t mounted_uid; 724 724 compat_pid_t wdog_pid; 725 725 unsigned char mounted_vol[NCP_VOLNAME_LEN + 1]; 726 726 compat_uint_t time_out; 727 727 compat_uint_t retry_count; 728 728 compat_uint_t flags; 729 - compat_uid_t uid; 730 - compat_gid_t gid; 729 + __compat_uid_t uid; 730 + __compat_gid_t gid; 731 731 compat_mode_t file_mode; 732 732 compat_mode_t dir_mode; 733 733 }; ··· 784 784 785 785 struct compat_smb_mount_data { 786 786 compat_int_t version; 787 - compat_uid_t mounted_uid; 788 - compat_uid_t uid; 789 - compat_gid_t gid; 787 + __compat_uid_t mounted_uid; 788 + __compat_uid_t uid; 789 + __compat_gid_t gid; 790 790 compat_mode_t file_mode; 791 791 compat_mode_t dir_mode; 792 792 }; ··· 1808 1808 compat_dev_t ex32_dev; 1809 1809 compat_ino_t ex32_ino; 1810 1810 compat_int_t ex32_flags; 1811 - compat_uid_t ex32_anon_uid; 1812 - compat_gid_t ex32_anon_gid; 1811 + __compat_uid_t ex32_anon_uid; 1812 + __compat_gid_t ex32_anon_gid; 1813 1813 }; 1814 1814 1815 1815 struct compat_nfsctl_fdparm {
+10 -10
include/asm-ia64/compat.h
··· 13 13 typedef s32 compat_clock_t; 14 14 typedef s32 compat_key_t; 15 15 typedef s32 compat_pid_t; 16 - typedef u16 compat_uid_t; 17 - typedef u16 compat_gid_t; 18 - typedef u32 compat_uid32_t; 19 - typedef u32 compat_gid32_t; 16 + typedef u16 __compat_uid_t; 17 + typedef u16 __compat_gid_t; 18 + typedef u32 __compat_uid32_t; 19 + typedef u32 __compat_gid32_t; 20 20 typedef u16 compat_mode_t; 21 21 typedef u32 compat_ino_t; 22 22 typedef u16 compat_dev_t; ··· 50 50 compat_ino_t st_ino; 51 51 compat_mode_t st_mode; 52 52 compat_nlink_t st_nlink; 53 - compat_uid_t st_uid; 54 - compat_gid_t st_gid; 53 + __compat_uid_t st_uid; 54 + __compat_gid_t st_gid; 55 55 compat_dev_t st_rdev; 56 56 u16 __pad2; 57 57 u32 st_size; ··· 120 120 121 121 struct compat_ipc64_perm { 122 122 compat_key_t key; 123 - compat_uid32_t uid; 124 - compat_gid32_t gid; 125 - compat_uid32_t cuid; 126 - compat_gid32_t cgid; 123 + __compat_uid32_t uid; 124 + __compat_gid32_t gid; 125 + __compat_uid32_t cuid; 126 + __compat_gid32_t cgid; 127 127 unsigned short mode; 128 128 unsigned short __pad1; 129 129 unsigned short seq;
+6 -4
include/asm-mips/compat.h
··· 15 15 typedef s32 compat_suseconds_t; 16 16 17 17 typedef s32 compat_pid_t; 18 - typedef s32 compat_uid_t; 19 - typedef s32 compat_gid_t; 18 + typedef u32 __compat_uid_t; 19 + typedef u32 __compat_gid_t; 20 + typedef u32 __compat_uid32_t; 21 + typedef u32 __compat_gid32_t; 20 22 typedef u32 compat_mode_t; 21 23 typedef u32 compat_ino_t; 22 24 typedef u32 compat_dev_t; ··· 54 52 compat_ino_t st_ino; 55 53 compat_mode_t st_mode; 56 54 compat_nlink_t st_nlink; 57 - compat_uid_t st_uid; 58 - compat_gid_t st_gid; 55 + __compat_uid32_t st_uid; 56 + __compat_gid32_t st_gid; 59 57 compat_dev_t st_rdev; 60 58 s32 st_pad2[2]; 61 59 compat_off_t st_size;
+6 -4
include/asm-parisc/compat.h
··· 13 13 typedef s32 compat_time_t; 14 14 typedef s32 compat_clock_t; 15 15 typedef s32 compat_pid_t; 16 - typedef u32 compat_uid_t; 17 - typedef u32 compat_gid_t; 16 + typedef u32 __compat_uid_t; 17 + typedef u32 __compat_gid_t; 18 + typedef u32 __compat_uid32_t; 19 + typedef u32 __compat_gid32_t; 18 20 typedef u16 compat_mode_t; 19 21 typedef u32 compat_ino_t; 20 22 typedef u32 compat_dev_t; ··· 69 67 compat_dev_t st_realdev; 70 68 u16 st_basemode; 71 69 u16 st_spareshort; 72 - compat_uid_t st_uid; 73 - compat_gid_t st_gid; 70 + __compat_uid32_t st_uid; 71 + __compat_gid32_t st_gid; 74 72 u32 st_spare4[3]; 75 73 }; 76 74
+10 -8
include/asm-ppc64/compat.h
··· 13 13 typedef s32 compat_time_t; 14 14 typedef s32 compat_clock_t; 15 15 typedef s32 compat_pid_t; 16 - typedef u32 compat_uid_t; 17 - typedef u32 compat_gid_t; 16 + typedef u32 __compat_uid_t; 17 + typedef u32 __compat_gid_t; 18 + typedef u32 __compat_uid32_t; 19 + typedef u32 __compat_gid32_t; 18 20 typedef u32 compat_mode_t; 19 21 typedef u32 compat_ino_t; 20 22 typedef u32 compat_dev_t; ··· 50 48 compat_ino_t st_ino; 51 49 compat_mode_t st_mode; 52 50 compat_nlink_t st_nlink; 53 - compat_uid_t st_uid; 54 - compat_gid_t st_gid; 51 + __compat_uid32_t st_uid; 52 + __compat_gid32_t st_gid; 55 53 compat_dev_t st_rdev; 56 54 compat_off_t st_size; 57 55 compat_off_t st_blksize; ··· 146 144 */ 147 145 struct compat_ipc64_perm { 148 146 compat_key_t key; 149 - compat_uid_t uid; 150 - compat_gid_t gid; 151 - compat_uid_t cuid; 152 - compat_gid_t cgid; 147 + __compat_uid_t uid; 148 + __compat_gid_t gid; 149 + __compat_uid_t cuid; 150 + __compat_gid_t cgid; 153 151 compat_mode_t mode; 154 152 unsigned int seq; 155 153 unsigned int __pad2;
+10 -10
include/asm-s390/compat.h
··· 13 13 typedef s32 compat_time_t; 14 14 typedef s32 compat_clock_t; 15 15 typedef s32 compat_pid_t; 16 - typedef u16 compat_uid_t; 17 - typedef u16 compat_gid_t; 18 - typedef u32 compat_uid32_t; 19 - typedef u32 compat_gid32_t; 16 + typedef u16 __compat_uid_t; 17 + typedef u16 __compat_gid_t; 18 + typedef u32 __compat_uid32_t; 19 + typedef u32 __compat_gid32_t; 20 20 typedef u16 compat_mode_t; 21 21 typedef u32 compat_ino_t; 22 22 typedef u16 compat_dev_t; ··· 51 51 compat_ino_t st_ino; 52 52 compat_mode_t st_mode; 53 53 compat_nlink_t st_nlink; 54 - compat_uid_t st_uid; 55 - compat_gid_t st_gid; 54 + __compat_uid_t st_uid; 55 + __compat_gid_t st_gid; 56 56 compat_dev_t st_rdev; 57 57 u16 __pad2; 58 58 u32 st_size; ··· 140 140 141 141 struct compat_ipc64_perm { 142 142 compat_key_t key; 143 - compat_uid32_t uid; 144 - compat_gid32_t gid; 145 - compat_uid32_t cuid; 146 - compat_gid32_t cgid; 143 + __compat_uid32_t uid; 144 + __compat_gid32_t gid; 145 + __compat_uid32_t cuid; 146 + __compat_gid32_t cgid; 147 147 compat_mode_t mode; 148 148 unsigned short __pad1; 149 149 unsigned short seq;
+10 -8
include/asm-sparc64/compat.h
··· 12 12 typedef s32 compat_time_t; 13 13 typedef s32 compat_clock_t; 14 14 typedef s32 compat_pid_t; 15 - typedef u16 compat_uid_t; 16 - typedef u16 compat_gid_t; 15 + typedef u16 __compat_uid_t; 16 + typedef u16 __compat_gid_t; 17 + typedef u32 __compat_uid32_t; 18 + typedef u32 __compat_gid32_t; 17 19 typedef u16 compat_mode_t; 18 20 typedef u32 compat_ino_t; 19 21 typedef u16 compat_dev_t; ··· 49 47 compat_ino_t st_ino; 50 48 compat_mode_t st_mode; 51 49 compat_nlink_t st_nlink; 52 - compat_uid_t st_uid; 53 - compat_gid_t st_gid; 50 + __compat_uid_t st_uid; 51 + __compat_gid_t st_gid; 54 52 compat_dev_t st_rdev; 55 53 compat_off_t st_size; 56 54 compat_time_t st_atime; ··· 179 177 180 178 struct compat_ipc64_perm { 181 179 compat_key_t key; 182 - __kernel_uid_t uid; 183 - __kernel_gid_t gid; 184 - __kernel_uid_t cuid; 185 - __kernel_gid_t cgid; 180 + __compat_uid32_t uid; 181 + __compat_gid32_t gid; 182 + __compat_uid32_t cuid; 183 + __compat_gid32_t cgid; 186 184 unsigned short __pad1; 187 185 compat_mode_t mode; 188 186 unsigned short __pad2;
+10 -10
include/asm-x86_64/compat.h
··· 14 14 typedef s32 compat_time_t; 15 15 typedef s32 compat_clock_t; 16 16 typedef s32 compat_pid_t; 17 - typedef u16 compat_uid_t; 18 - typedef u16 compat_gid_t; 19 - typedef u32 compat_uid32_t; 20 - typedef u32 compat_gid32_t; 17 + typedef u16 __compat_uid_t; 18 + typedef u16 __compat_gid_t; 19 + typedef u32 __compat_uid32_t; 20 + typedef u32 __compat_gid32_t; 21 21 typedef u16 compat_mode_t; 22 22 typedef u32 compat_ino_t; 23 23 typedef u16 compat_dev_t; ··· 52 52 compat_ino_t st_ino; 53 53 compat_mode_t st_mode; 54 54 compat_nlink_t st_nlink; 55 - compat_uid_t st_uid; 56 - compat_gid_t st_gid; 55 + __compat_uid_t st_uid; 56 + __compat_gid_t st_gid; 57 57 compat_dev_t st_rdev; 58 58 u16 __pad2; 59 59 u32 st_size; ··· 122 122 123 123 struct compat_ipc64_perm { 124 124 compat_key_t key; 125 - compat_uid32_t uid; 126 - compat_gid32_t gid; 127 - compat_uid32_t cuid; 128 - compat_gid32_t cgid; 125 + __compat_uid32_t uid; 126 + __compat_gid32_t gid; 127 + __compat_uid32_t cuid; 128 + __compat_gid32_t cgid; 129 129 unsigned short mode; 130 130 unsigned short __pad1; 131 131 unsigned short seq;
+3
include/linux/compat.h
··· 18 18 #define compat_jiffies_to_clock_t(x) \ 19 19 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) 20 20 21 + typedef __compat_uid32_t compat_uid_t; 22 + typedef __compat_gid32_t compat_gid_t; 23 + 21 24 struct rusage; 22 25 23 26 struct compat_itimerspec {
+6 -6
ipc/compat.c
··· 42 42 43 43 struct compat_ipc_perm { 44 44 key_t key; 45 - compat_uid_t uid; 46 - compat_gid_t gid; 47 - compat_uid_t cuid; 48 - compat_gid_t cgid; 45 + __compat_uid_t uid; 46 + __compat_gid_t gid; 47 + __compat_uid_t cuid; 48 + __compat_gid_t cgid; 49 49 compat_mode_t mode; 50 50 unsigned short seq; 51 51 }; ··· 174 174 struct compat_ipc_perm __user *up) 175 175 { 176 176 int err; 177 - compat_uid_t u; 178 - compat_gid_t g; 177 + __compat_uid_t u; 178 + __compat_gid_t g; 179 179 180 180 err = __put_user(p->key, &up->key); 181 181 SET_UID(u, p->uid);