coredump - as root not only if euid switched
Quoted 22 lines · Andrew Morton
Quoted 7 lines · Peter W�chtler
While it's more secure to not dump core at all if the program has
switched euid, it's also very unpractical. Since only programs started from root, being setuid root or haveCAP_SETUIDit's far more practical to dump as root.root mode 600. This is the bahavior of Solaris.Quoted 7 lines
The current implementation does not ensure that an existing core file is only readable as root, i.e. after dumping the ownership and mode is unchanged.
Besides
mm->dumpableto avoid recursive core dumps, on setuid files the dumpable flag still prevents a core dump while seteuid & co will result in a core only readable as root.It's a bit sad to add another function call level to
sys_unlink()simply because the core dumping code needs it.Is it not possible to call
sys_unlink()directly from there? Something likelong
kernel_unlink(const char *name)
Quoted 9 lines
{
mm_segment_t old_fs = get_fs();
long ret;
set_fs(KERNEL_DS);
ret = sys_unlink(name);
set_fs(old_fs);
return ret;
} And you're asking me? ;)
While getname() has a check for user/kernelspace - do you really care about "the overhead" for a function call level with 1 argument? Uhm, probably if you even care to write this..
What is the cost for switching the segments?
But I agree that sys_unlink should be the fast call and dumping core is the exception :)
would fastcall do_unlink() help? I guess the arg is then passed in a register
Quoted 8 lines · Peter Waechtler
Quoted 8 lines
Is it not possible to call
sys_unlink()directly from there? Something likelong
kernel_unlink(const char *name){ mm_segment_t old_fs = get_fs(); long ret;
Quoted 7 lines
Quoted 5 lines
set_fs(KERNEL_DS); ret = sys_unlink(name); set_fs(old_fs); return ret; }And you're asking me? ;)
Well someone has to know ;)
Quoted 3 lines
While
getname()has a check for user/kernelspace - do you really care about "the overhead" for a function call level with 1 argument? Uhm, probably if you even care to write this..
It's very small, but heck, we unlink a lot more often than we dump core. Most of us, that is.
Quoted 1 line
What is the cost for switching the segments?
Teeny.
Quoted 5 lines
But I agree that
sys_unlinkshould be the fast call and dumping core is the exception :)would fastcall
do_unlink()help? I guess the arg is then passed in a register
I've never been able to measure any size or space benefit for fastcall, and we do it via compiler options kernel-wide nowadays.
The above will work fine. You can probably just open-code it at the place where you're unlinking the file.
(why are you trying to unlink the old file anyway?)