Commit 202e5979af4d91c7ca05892641131dee22653259

Authored by Stephen Rothwell
Committed by Linus Torvalds
1 parent 8dbfc5cfdc

[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>

Showing 11 changed files with 87 additions and 76 deletions Side-by-side Diff

arch/mips/kernel/linux32.c
... ... @@ -546,20 +546,20 @@
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;
... ... @@ -720,14 +720,14 @@
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,9 +784,9 @@
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,8 +1808,8 @@
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 {
include/asm-ia64/compat.h
... ... @@ -13,10 +13,10 @@
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,8 +50,8 @@
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,10 +120,10 @@
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;
include/asm-mips/compat.h
... ... @@ -15,8 +15,10 @@
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;
... ... @@ -52,8 +54,8 @@
52 54 compat_ino_t st_ino;
53 55 compat_mode_t st_mode;
54 56 compat_nlink_t st_nlink;
55   - compat_uid_t st_uid;
56   - compat_gid_t st_gid;
  57 + __compat_uid32_t st_uid;
  58 + __compat_gid32_t st_gid;
57 59 compat_dev_t st_rdev;
58 60 s32 st_pad2[2];
59 61 compat_off_t st_size;
include/asm-parisc/compat.h
... ... @@ -13,8 +13,10 @@
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;
... ... @@ -67,8 +69,8 @@
67 69 compat_dev_t st_realdev;
68 70 u16 st_basemode;
69 71 u16 st_spareshort;
70   - compat_uid_t st_uid;
71   - compat_gid_t st_gid;
  72 + __compat_uid32_t st_uid;
  73 + __compat_gid32_t st_gid;
72 74 u32 st_spare4[3];
73 75 };
74 76  
include/asm-ppc64/compat.h
... ... @@ -13,8 +13,10 @@
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;
... ... @@ -48,8 +50,8 @@
48 50 compat_ino_t st_ino;
49 51 compat_mode_t st_mode;
50 52 compat_nlink_t st_nlink;
51   - compat_uid_t st_uid;
52   - compat_gid_t st_gid;
  53 + __compat_uid32_t st_uid;
  54 + __compat_gid32_t st_gid;
53 55 compat_dev_t st_rdev;
54 56 compat_off_t st_size;
55 57 compat_off_t st_blksize;
... ... @@ -144,10 +146,10 @@
144 146 */
145 147 struct compat_ipc64_perm {
146 148 compat_key_t key;
147   - compat_uid_t uid;
148   - compat_gid_t gid;
149   - compat_uid_t cuid;
150   - compat_gid_t cgid;
  149 + __compat_uid_t uid;
  150 + __compat_gid_t gid;
  151 + __compat_uid_t cuid;
  152 + __compat_gid_t cgid;
151 153 compat_mode_t mode;
152 154 unsigned int seq;
153 155 unsigned int __pad2;
include/asm-s390/compat.h
... ... @@ -13,10 +13,10 @@
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,8 +51,8 @@
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,10 +140,10 @@
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;
include/asm-sparc64/compat.h
... ... @@ -12,8 +12,10 @@
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;
... ... @@ -47,8 +49,8 @@
47 49 compat_ino_t st_ino;
48 50 compat_mode_t st_mode;
49 51 compat_nlink_t st_nlink;
50   - compat_uid_t st_uid;
51   - compat_gid_t st_gid;
  52 + __compat_uid_t st_uid;
  53 + __compat_gid_t st_gid;
52 54 compat_dev_t st_rdev;
53 55 compat_off_t st_size;
54 56 compat_time_t st_atime;
... ... @@ -177,10 +179,10 @@
177 179  
178 180 struct compat_ipc64_perm {
179 181 compat_key_t key;
180   - __kernel_uid_t uid;
181   - __kernel_gid_t gid;
182   - __kernel_uid_t cuid;
183   - __kernel_gid_t cgid;
  182 + __compat_uid32_t uid;
  183 + __compat_gid32_t gid;
  184 + __compat_uid32_t cuid;
  185 + __compat_gid32_t cgid;
184 186 unsigned short __pad1;
185 187 compat_mode_t mode;
186 188 unsigned short __pad2;
include/asm-x86_64/compat.h
... ... @@ -14,10 +14,10 @@
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,8 +52,8 @@
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,10 +122,10 @@
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;
include/linux/compat.h
... ... @@ -18,6 +18,9 @@
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 {
... ... @@ -42,10 +42,10 @@
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,8 +174,8 @@
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);