kernel: make /proc/kallsyms mode 400 to reduce ease of attacking
Quoted 10 lines
Quoted 6 lines · Sarah Sharp
.config and dmesg are attached. The box is running klogd 1.5.5ubuntu3 (from Jaunty). Yes, I know that's old. I read the bit in the commit about changing the permissions of kallsyms after boot, but if I can't boot that doesn't help. Perhaps this can be made a configuration option?
Quoted 3 lines
It's not worth a config option.
If it actually breaks user-space, I think we should just revert it.
User space klogd is what's broken in this case:
ksyms = fopen(KSYMS, "r");
if ( ksyms == NULL )
{
if ( errno == ENOENT )
Syslog(LOG_INFO, "No module symbols loaded - "
"kernel modules not enabled.\n");
else
Syslog(LOG_ERR, "Error loading kernel symbols " \
"- %s\n", strerror(errno));
fclose(ksyms);
return(0);
}The fclose(NULL) is a bug, as I don't think the standards require that to be handled gracefully.
Quoted 1 line
It's kind of sad to default to the world-visible thing,
klogd also gets symbols from System.map, so /proc/kallsyms access is not a strict requirement.
I haven't checked to see if klogd can work without a symbol source at all, but I'll wager it can.
Regards,
Andy
Quoted 4 lines · Andy Walls
Quoted 2 lines
If it actually breaks user-space, I think we should just revert it.
User space klogd is what's broken in this case:
Sure. I'm not surprised. I didn't really expect the /proc/kallsyms mode change to trigger anything like what Sarah reported, and user-space just being buggy because the error case had never even been tested is quite understandable.
But the thing is, it doesn't even matter.
The rule is not "we don't break non-buggy user space" or "we don't break reasonable user-space". The rule is simply "we don't break user-space".
Even if the breakage is totally incidental, that doesn't help the _user_. It's still breakage.
We still have magic scheduler debug options to run children before parents after fork, simply because that used to _hide_ a race condition in some older "bash" versions (or maybe it was the other way around, whatever).
The thing is, bugs happen. And if they never had test coverage, we can't blame people for them. Saying "tough luck, we changed it, and you did something wrong" may be manly, but it's also unacceptable. The developer may fix his bug, but there's still users out there.
Now, there _are_ exceptions. There are always exceptions. Intelligent people don't run things off a script, and it's obviously always to some degree a judgment call. The breakage has to be balanced against the upsides. If the kernel behavior change is due to some fundamental security issue or a major redesign that we _had_ to do to make progress, and the user-level breakage is reasonably well-contained, we'll just say "sorry, we had to do it".
In this case, the upside just wasn't big enough to accept _any_ breakage, especially since people and distributions can just do the "chmod" themselves if they want to. There was a lot of discussion whether the patch should even go in in the first place. So this time, the "let's just revert it" was a very easy decision for me.
Linus
Quoted 5 lines · Linus Torvalds
In this case, the upside just wasn't big enough to accept _any_ breakage, especially since people and distributions can just do the "chmod" themselves if they want to. There was a lot of discussion whether the patch should even go in in the first place. So this time, the "let's just revert it" was a very easy decision for me.
The downside is that /proc can be remounted multiple times for different containers, etc. Having to patch everything that mounts /proc to do the chmod seems much more painful that fixing a simple userspace bug in an old klog daemon.
(For example, rsyslogd handles this fine since it's root to open it, and even if it fails, it doesn't do the broken fclose().)
-Kees
Signature · 2 lines
Kees Cook Ubuntu Security Team
Quoted 7 lines · Kees Cook
Quoted 5 lines · Linus Torvalds
In this case, the upside just wasn't big enough to accept _any_ breakage, especially since people and distributions can just do the "chmod" themselves if they want to. There was a lot of discussion whether the patch should even go in in the first place. So this time, the "let's just revert it" was a very easy decision for me.
Quoted 7 lines
The downside is that /proc can be remounted multiple times for different containers, etc. Having to patch everything that mounts /proc to do the chmod seems much more painful that fixing a simple userspace bug in an old klog daemon.
(For example, rsyslogd handles this fine since it's root to open it, and even if it fails, it doesn't do the broken
fclose().)
If it is a pain only for buggy old/legacy userspace like klogd or a few tools, it would still be very useful as a Kconfig option defaulting to disabled.
As an user and sysadmin, I'd rather not have to find out every place that mounts /proc in a chroot to chmod all relevant files :( That's fighting a loosing battle, unlike fixing broken tools (which at least will stay fixed).
Distros could get any fixing done they require, and then enable it for all their users. Ubuntu and Debian are likely to do it, and I'd guess so is Fedora.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 14 lines · Henrique de Moraes Holschuh
Quoted 7 lines · Kees Cook
Quoted 5 lines · Linus Torvalds
In this case, the upside just wasn't big enough to accept _any_ breakage, especially since people and distributions can just do the "chmod" themselves if they want to. There was a lot of discussion whether the patch should even go in in the first place. So this time, the "let's just revert it" was a very easy decision for me.
Quoted 5 lines
The downside is that /proc can be remounted multiple times for different containers, etc. Having to patch everything that mounts /proc to do the chmod seems much more painful that fixing a simple userspace bug in an old klog daemon.
Quoted 3 lines
As an user and sysadmin, I'd rather not have to find out every place that mounts /proc in a chroot to chmod all relevant files :( That's fighting a loosing battle, unlike fixing broken tools (which at least will stay fixed).
There's only one set of "kallsyms" permissions. If you chmod it in one mount of proc, the permissions apply in *all* mounts of proc, current or future.
So you don't have to find every place that mounts /proc - you can just chmod it once at startup and be done.
- Kevin