* 32bit UIDs fixes and cleanups
@ 2000-01-17 0:54 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2000-01-17 0:54 UTC (permalink / raw)
To: libc-hacker
Hi!
This is what I changed in 32bit uid support so far (am hacking on new IPC
stuff right now):
For syscalls which use low2high[ug]id in the kernel (e.g. chown family,
etc.), we have to accept -1 (which in some cases would be refused, e.g. new
i386 lchown), but should not IMHO accept 0xffff, since it will do a
different thing than the user expects.
m68k chown was broken.
On sparc, we introduced setres[ug]id just now, and only in the 32bit uid
variants, so there is no need for backward compatibility.
I wonder why we accept setuid(-1) etc. It is quite inconsistent. Why we
accept that and return EINVAL for -2? IMHO we should not accept it at all,
if user wants to setuid(65535), he can do it that way.
2000-01-17 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/i386/chown.c (__syscall_chown): Use proper
prototype.
(__real_chown): Return EINVAL if owner or group are out of the range
-1U .. 65534.
* sysdeps/unix/sysv/linux/i386/lchown.c (__lchown): Likewise.
* sysdeps/unix/sysv/linux/i386/fchown.c (__fchown): Likewise.
* sysdeps/unix/sysv/linux/i386/setgid.c (__setgid): Add comment.
* sysdeps/unix/sysv/linux/i386/setuid.c (__setuid): Add comment.
* sysdeps/unix/sysv/linux/i386/setresuid.c (__setresuid): Return
EINVAL if ruid, euid or suid are out of the range -1U .. 65534.
* sysdeps/unix/sysv/linux/i386/setresgid.c (__setresgid): Similarly.
* sysdeps/unix/sysv/linux/i386/setreuid.c (__setreuid): Simplify.
* sysdeps/unix/sysv/linux/i386/setregid.c (__setregid): Likewise.
* sysdeps/unix/sysv/linux/m68k/chown.c (__syscall_chown): Use proper
prototype.
Don't include non-existant header.
(__chown): Return EINVAL if owner or group are out of the range
-1U .. 65534.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list (setresuid,
setresgid): Inherit standard linux/syscalls.list definitions.
* sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c: Remove.
* sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c: Remove.
* sysdeps/unix/sysv/linux/syscalls.list (setresgid): Provide
__setresgid symbol.
--- libc/sysdeps/unix/sysv/linux/i386/chown.c.jj Mon Jan 17 07:58:55 2000
+++ libc/sysdeps/unix/sysv/linux/i386/chown.c Mon Jan 17 08:32:23 2000
@@ -38,7 +38,7 @@
*/
extern int __syscall_chown (const char *__file,
- uid_t __owner, gid_t __group);
+ __kernel_uid_t __owner, __kernel_gid_t __group);
#if defined __NR_lchown || __ASSUME_LCHOWN_SYSCALL > 0
/* Running under Linux > 2.1.80. */
@@ -76,6 +76,13 @@ __real_chown (const char *file, uid_t ow
__libc_missing_32bit_uids = 1;
}
# endif /* __NR_chown32 */
+ if ( ((owner + 1) > (__kernel_uid_t) -1U) ||
+ ((group + 1) > (__kernel_gid_t) -1U) )
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
result = INLINE_SYSCALL (chown, 3, file, owner, group);
if (result >= 0 || errno != ENOSYS)
@@ -105,6 +112,13 @@ __real_chown (const char *file, uid_t ow
__libc_missing_32bit_uids = 1;
}
# endif /* __NR_chown32 */
+ if ( ((owner + 1) > (__kernel_uid_t) -1U) ||
+ ((group + 1) > (__kernel_gid_t) -1U) )
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
return INLINE_SYSCALL (chown, 3, file, owner, group);
# endif
}
--- libc/sysdeps/unix/sysv/linux/i386/lchown.c.jj Mon Jan 17 06:18:45 2000
+++ libc/sysdeps/unix/sysv/linux/i386/lchown.c Mon Jan 17 08:33:33 2000
@@ -60,8 +60,8 @@ __lchown (const char *file, uid_t owner,
}
# endif /* __NR_lchown32 */
- if ( (owner != (uid_t) ((__kernel_uid_t) owner)) ||
- (group != (gid_t) ((__kernel_gid_t) group)) )
+ if ( ((owner + 1) > (__kernel_uid_t) -1U) ||
+ ((group + 1) > (__kernel_gid_t) -1U) )
{
__set_errno (EINVAL);
return -1;
--- libc/sysdeps/unix/sysv/linux/i386/fchown.c.jj Mon Jan 17 06:18:52 2000
+++ libc/sysdeps/unix/sysv/linux/i386/fchown.c Mon Jan 17 08:29:34 2000
@@ -59,8 +59,8 @@ __fchown (int fd, uid_t owner, gid_t gro
}
# endif /* __NR_fchown32 */
- if ( (owner != (uid_t) ((__kernel_uid_t) owner)) ||
- (group != (gid_t) ((__kernel_gid_t) group)) )
+ if ( ((owner + 1) > (__kernel_uid_t) -1U) ||
+ ((group + 1) > (__kernel_gid_t) -1U) )
{
__set_errno (EINVAL);
return -1;
--- libc/sysdeps/unix/sysv/linux/i386/setgid.c.jj Mon Jan 17 07:58:55 2000
+++ libc/sysdeps/unix/sysv/linux/i386/setgid.c Mon Jan 17 08:48:05 2000
@@ -60,6 +60,7 @@ __setgid (gid_t gid)
}
# endif /* __NR_setgid32 */
+ /* This is wrong. We should not accept gid -1U. */
if (gid == (gid_t) ~0
|| gid != (gid_t) ((__kernel_gid_t) gid))
{
--- libc/sysdeps/unix/sysv/linux/i386/setuid.c.jj Mon Jan 17 07:58:55 2000
+++ libc/sysdeps/unix/sysv/linux/i386/setuid.c Mon Jan 17 08:49:44 2000
@@ -58,6 +58,7 @@ __setuid (uid_t uid)
}
# endif /* __NR_setuid32 */
+ /* This is wrong. We should not accept gid -1U. */
if (uid == (uid_t) ~0
|| uid != (uid_t) ((__kernel_uid_t) uid))
{
--- libc/sysdeps/unix/sysv/linux/i386/setresuid.c.jj Mon Jan 17 07:58:55 2000
+++ libc/sysdeps/unix/sysv/linux/i386/setresuid.c Mon Jan 17 08:51:59 2000
@@ -62,9 +62,9 @@ __setresuid (uid_t ruid, uid_t euid, uid
}
# endif /* __NR_setresuid32 */
- if ((ruid != (uid_t) -1 && ruid != (uid_t) (__kernel_uid_t) ruid)
- || (euid != (uid_t) -1 && euid != (uid_t) (__kernel_uid_t) euid)
- || (suid != (uid_t) -1 && suid != (uid_t) (__kernel_uid_t) suid))
+ if ( ((ruid + 1) > (__kernel_uid_t) -1U) ||
+ ((euid + 1) > (__kernel_uid_t) -1U) ||
+ ((suid + 1) > (__kernel_uid_t) -1U) )
{
__set_errno (EINVAL);
return -1;
--- libc/sysdeps/unix/sysv/linux/i386/setresgid.c.jj Mon Jan 17 07:58:55 2000
+++ libc/sysdeps/unix/sysv/linux/i386/setresgid.c Mon Jan 17 08:52:31 2000
@@ -62,9 +62,9 @@ setresgid (gid_t rgid, gid_t egid, gid_t
}
# endif /* __NR_setresgid32 */
- if ((rgid != (gid_t) -1 && rgid != (gid_t) (__kernel_gid_t) rgid)
- || (egid != (gid_t) -1 && egid != (gid_t) (__kernel_gid_t) egid)
- || (sgid != (gid_t) -1 && sgid != (gid_t) (__kernel_gid_t) sgid))
+ if ( ((rgid + 1) > (__kernel_gid_t) -1U) ||
+ ((egid + 1) > (__kernel_gid_t) -1U) ||
+ ((sgid + 1) > (__kernel_gid_t) -1U) )
{
__set_errno (EINVAL);
return -1;
--- libc/sysdeps/unix/sysv/linux/i386/setregid.c.jj Mon Jan 17 07:58:55 2000
+++ libc/sysdeps/unix/sysv/linux/i386/setregid.c Mon Jan 17 08:53:11 2000
@@ -59,8 +59,8 @@ __setregid (gid_t rgid, gid_t egid)
__libc_missing_32bit_uids = 1;
}
# endif /* __NR_setregid32 */
- if ((rgid != (gid_t) -1 && rgid != (gid_t) (__kernel_gid_t) rgid)
- || (egid != (gid_t) -1 && egid != (gid_t) (__kernel_gid_t) egid))
+ if ( ((rgid + 1) > (__kernel_gid_t) -1U) ||
+ ((egid + 1) > (__kernel_gid_t) -1U) )
{
__set_errno (EINVAL);
return -1;
--- libc/sysdeps/unix/sysv/linux/i386/setreuid.c.jj Mon Jan 17 07:58:55 2000
+++ libc/sysdeps/unix/sysv/linux/i386/setreuid.c Mon Jan 17 08:54:14 2000
@@ -59,8 +59,8 @@ __setreuid (uid_t ruid, uid_t euid)
__libc_missing_32bit_uids = 1;
}
# endif /* __NR_setreuid32 */
- if ((ruid != (uid_t) -1 && ruid != (uid_t) (__kernel_uid_t) ruid)
- || (euid != (uid_t) -1 && euid != (uid_t) (__kernel_uid_t) euid))
+ if ( ((ruid + 1) > (__kernel_uid_t) -1U) ||
+ ((euid + 1) > (__kernel_uid_t) -1U) )
{
__set_errno (EINVAL);
return -1;
--- libc/sysdeps/unix/sysv/linux/m68k/chown.c.jj Mon Jan 17 06:19:42 2000
+++ libc/sysdeps/unix/sysv/linux/m68k/chown.c Mon Jan 17 08:56:44 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,21 +24,28 @@
#include <linux/posix_types.h>
-#include <sysdeps/unix/sysv/linux/32bit_uid_compat.h>
-
extern int __syscall_chown (const char *__file,
- uid_t __owner, gid_t __group);
+ __kernel_uid_t __owner, __kernel_gid_t __group);
#ifdef __NR_chown32
extern int __syscall_chown32 (const char *__file,
__kernel_uid32_t owner, __kernel_gid32_t group);
+
+# if __ASSUME_32BITUIDS == 0
+/* This variable is shared with all files that need to check for 32bit
+ uids. */
+extern int __libc_missing_32bit_uids;
+# endif
#endif /* __NR_chown32 */
int
__chown (const char *file, uid_t owner, gid_t group)
{
-#ifdef __NR_chown32
- if (__libc_missing_32bit_uids != NO_HIGHUIDS)
+# if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (chown32, 3, file, owner, group);
+# else
+# ifdef __NR_chown32
+ if (!__libc_missing_32bit_uids)
{
int result;
int saved_errno = errno;
@@ -48,10 +55,19 @@ __chown (const char *file, uid_t owner,
return result;
__set_errno (saved_errno);
- __libc_missing_32bit_uids = NO_HIGHUIDS;
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_chown32 */
+
+ if ( ((owner + 1) > (__kernel_uid_t) -1U) ||
+ ((group + 1) > (__kernel_gid_t) -1U) )
+ {
+ __set_errno (EINVAL);
+ return -1;
}
-#endif /* __NR_chown32 */
return INLINE_SYSCALL (chown, 3, file, owner, group);
+
+# endif
}
weak_alias (__chown, chown)
--- libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list.jj Tue Dec 28 11:33:43 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list Mon Jan 17 09:03:50 2000
@@ -8,8 +8,6 @@ s_setfsuid setfsuid setfsuid 1 __syscall
s_setgid setgid setgid 1 __syscall_setgid
s_setgroups setgroups setgroups 2 __syscall_setgroups
s_setregid setregid setregid 2 __syscall_setregid
-s_setresgid setresgid setresgid 3 __syscall_setresgid
-s_setresuid setresuid setresuid 3 __syscall_setresuid
s_setreuid setreuid setreuid 2 __syscall_setreuid
s_setrlimit setrlimit setrlimit 3 __syscall_setrlimit
s_ipc msgget ipc 5 __syscall_ipc
--- libc/sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c.jj Fri Oct 16 18:31:58 1998
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c Mon Jan 17 09:09:25 2000
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/setresgid.c>
--- libc/sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c.jj Fri Oct 16 18:32:03 1998
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c Mon Jan 17 09:09:28 2000
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/setresuid.c>
--- libc/sysdeps/unix/sysv/linux/syscalls.list.jj Fri Dec 10 15:15:34 1999
+++ libc/sysdeps/unix/sysv/linux/syscalls.list Mon Jan 17 09:08:40 2000
@@ -53,7 +53,7 @@ setfsgid EXTRA setfsgid 1 setfsgid
setfsuid EXTRA setfsuid 1 setfsuid
setpgid - setpgid 2 __setpgid setpgid
setresuid EXTRA setresuid 3 __setresuid setresuid
-setresgid EXTRA setresgid 3 setresgid
+setresgid EXTRA setresgid 3 __setresgid setresgid
sigaltstack - sigaltstack 2 __sigaltstack sigaltstack
sysinfo EXTRA sysinfo 1 sysinfo
swapon - swapon 2 __swapon swapon
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.39 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-01-17 0:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-17 0:54 32bit UIDs fixes and cleanups Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).