Bug 4459 - MIPS mips64 setregid and friends fail
Summary: MIPS mips64 setregid and friends fail
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: ports (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Roland McGrath
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-03 16:45 UTC by Peter Watkins
Modified: 2014-06-13 11:18 UTC (History)
1 user (show)

See Also:
Host: mips64el-gentoo-linux-gnu
Target: mips64el-gentoo-linux-gnu
Build: x86_64-pc-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments
setregid.c (705 bytes, text/x-csrc)
2007-05-03 16:47 UTC, Peter Watkins
Details
setresgid.c (727 bytes, text/x-csrc)
2007-05-03 16:48 UTC, Peter Watkins
Details
setresuid.c (727 bytes, text/x-csrc)
2007-05-03 16:48 UTC, Peter Watkins
Details
setreuid.c (705 bytes, text/x-csrc)
2007-05-03 16:48 UTC, Peter Watkins
Details
README (112 bytes, application/octet-stream)
2007-05-03 16:49 UTC, Peter Watkins
Details
gid.c (283 bytes, text/x-csrc)
2007-05-03 17:09 UTC, Peter Watkins
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Watkins 2007-05-03 16:45:04 UTC
Passing arg -1 on mips64 to setregid causes failures.

OK, -1 is a flag value for certain setuid and setgid system calls. The 32 bit
value in uid_t and gid_t is not sign extended by glibc when passed to the
kernel, but the kernel does sign extend in it's comparison check rgid !=
(gid_t)-1.

This may be broken on all mips64 versions of glibc.
Comment 1 Peter Watkins 2007-05-03 16:47:13 UTC
I have attached mips64 versions of certain files, as an example of how this
might be fixed. (A real glibc developer would likely do it differently.)

Comment 2 Peter Watkins 2007-05-03 16:47:49 UTC
Created attachment 1747 [details]
setregid.c
Comment 3 Peter Watkins 2007-05-03 16:48:14 UTC
Created attachment 1748 [details]
setresgid.c
Comment 4 Peter Watkins 2007-05-03 16:48:39 UTC
Created attachment 1749 [details]
setresuid.c
Comment 5 Peter Watkins 2007-05-03 16:48:57 UTC
Created attachment 1750 [details]
setreuid.c
Comment 6 Peter Watkins 2007-05-03 16:49:12 UTC
Created attachment 1751 [details]
README
Comment 7 Peter Watkins 2007-05-03 16:51:24 UTC
These files would go in the directory:
glibc-2.5/ports/sysdeps/unix/sysv/linux/mips/mips64

LTP tests with this 

setegid         pass
setgid          pass
setregid        pass
setresgid       pass
setresuid       pass
setreuid        pass
setsid          pass
setuid          pass
Comment 8 Peter Watkins 2007-05-03 17:09:52 UTC
Created attachment 1753 [details]
gid.c

Run gid.c as root on mips64 to see failure.
Comment 9 Joseph Myers 2009-01-17 12:46:04 UTC
I identified that there was a kernel bug with potential security implications
involved in <http://lkml.org/lkml/2007/6/4/376> (4 June 2007).  There were
a few replies concluding that the kernel should indeed be converting the
syscall arguments to the correct types (properly extended) before the main C
syscall implementations were called, but no actual fix.

It now appears someone else has rediscovered that there is, indeed, a security
issue here and managed to get more action, and it's fixed in 2.6.29-rc2.

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0029

So, no glibc bug here, but a kernel security bug that should be fixed in
the latest kernel, more than a year and a half after I first identified
the security issues in public.