
From: Tomas Olsson <tol@stacken.kth.se>

sys_getgroups16 (or rather groups16_to_user()) returns large gids
truncated.  Needs to be fixed, one way or another.  Don't know why the
other similar casts are still there.


---

 25-akpm/kernel/uid16.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff -puN kernel/uid16.c~getgroups16-fix kernel/uid16.c
--- 25/kernel/uid16.c~getgroups16-fix	2004-05-18 21:32:27.412718408 -0700
+++ 25-akpm/kernel/uid16.c	2004-05-18 21:32:27.416717800 -0700
@@ -39,7 +39,7 @@ asmlinkage long sys_setregid16(old_gid_t
 
 asmlinkage long sys_setgid16(old_gid_t gid)
 {
-	return sys_setgid((gid_t)gid);
+	return sys_setgid(low2highgid(gid));
 }
 
 asmlinkage long sys_setreuid16(old_uid_t ruid, old_uid_t euid)
@@ -49,7 +49,7 @@ asmlinkage long sys_setreuid16(old_uid_t
 
 asmlinkage long sys_setuid16(old_uid_t uid)
 {
-	return sys_setuid((uid_t)uid);
+	return sys_setuid(low2highuid(uid));
 }
 
 asmlinkage long sys_setresuid16(old_uid_t ruid, old_uid_t euid, old_uid_t suid)
@@ -88,12 +88,12 @@ asmlinkage long sys_getresgid16(old_gid_
 
 asmlinkage long sys_setfsuid16(old_uid_t uid)
 {
-	return sys_setfsuid((uid_t)uid);
+	return sys_setfsuid(low2highuid(uid));
 }
 
 asmlinkage long sys_setfsgid16(old_gid_t gid)
 {
-	return sys_setfsgid((gid_t)gid);
+	return sys_setfsgid(low2highgid(gid));
 }
 
 static int groups16_to_user(old_gid_t __user *grouplist,
@@ -103,7 +103,7 @@ static int groups16_to_user(old_gid_t __
 	old_gid_t group;
 
 	for (i = 0; i < group_info->ngroups; i++) {
-		group = (old_gid_t)GROUP_AT(group_info, i);
+		group = high2lowgid(GROUP_AT(group_info, i));
 		if (put_user(group, grouplist+i))
 			return -EFAULT;
 	}
@@ -120,7 +120,7 @@ static int groups16_from_user(struct gro
 	for (i = 0; i < group_info->ngroups; i++) {
 		if (get_user(group, grouplist+i))
 			return  -EFAULT;
-		GROUP_AT(group_info, i) = (gid_t)group;
+		GROUP_AT(group_info, i) = low2highgid(group);
 	}
 
 	return 0;

_
