diff options
author | jilles <jilles@FreeBSD.org> | 2011-01-28 15:29:35 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-01-28 15:29:35 +0000 |
commit | f43c10ba8c6f7334b043a441d0a2c449309da1b0 (patch) | |
tree | 7121d53955b54837c225a3956ee57db3b98b5a62 | |
parent | aa1f236de418a8ad6896d0c4f6c2c3e4dab28908 (diff) | |
download | FreeBSD-src-f43c10ba8c6f7334b043a441d0a2c449309da1b0.zip FreeBSD-src-f43c10ba8c6f7334b043a441d0a2c449309da1b0.tar.gz |
Do not trip a KASSERT if /dev/null cannot be opened for a setuid program.
The fdcheckstd() function makes sure fds 0, 1 and 2 are open by opening
/dev/null. If this fails (e.g. missing devfs or wrong permissions),
fdcheckstd() will return failure and the process will exit as if it received
SIGABRT. The KASSERT is only to check that kern_open() returns the expected
fd, given that it succeeded.
Tripping the KASSERT is most likely if fd 0 is open but fd 1 or 2 are not.
MFC after: 2 weeks
-rw-r--r-- | sys/kern/kern_descrip.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 2396dbd..d59bcb4 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2024,10 +2024,10 @@ fdcheckstd(struct thread *td) error = kern_open(td, "/dev/null", UIO_SYSSPACE, O_RDWR, 0); devnull = td->td_retval[0]; - KASSERT(devnull == i, ("oof, we didn't get our fd")); td->td_retval[0] = save; if (error) break; + KASSERT(devnull == i, ("oof, we didn't get our fd")); } else { error = do_dup(td, DUP_FIXED, devnull, i, &retval); if (error != 0) |