Skip to contentSkip to conversation

Local root exploit with kmod and modutils > 2.1.121

DISCUSSION Adam J. Richter 2 participants 2 messages Nov 14, 2000

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

The only secure fix I can see is to add SAFEMODE=1 to modprobe's environment and change exec_modprobe.

SAFEMODE may mean other things to other programs, so that
an ordinary user might set that environment variable for some other reason, and then get weird behavior if he or she has occasion to su to root. In general, you only want to use environment variables if either it is a user interface issue to keep the commands short (not an issue here, since nobody is typing in the command that requrest_module generates) or there is some well established convention that will handled in a particular way by subordinate child processes (e.g., PATH=....).

It would be much better to just add a command line option
to modprobe that request_module() would cause it treat the following argument as the module to load (you do not ever have to force argument processing to stop at that point, since module will be fully contained in the next argument, even if it contains space or linefeed).

Another possible approach would be to create a separate
/sbin/safe_modprobe. modprobe already behaves differently based on whether argv[0] ends in "modprobe", "insmod", "depmod", or "rmmod". So this would be in keeping with that convention. It would also be trivial to retrofit old systems. Just have some system boot script do:

echo /sbin/safe_modprobe > /proc/sys/kernel/modprobe

The issue of the kernel doing request_module() on arbitrary
strings is not just a security problem. It is also a namespace collision problem, which this security concern will give us the opportunity to fix. I have just been glad that no company has shipped a networking device called, say, "ext2". The non-constant module names that are loaded by request_module should have names like:

		fs-msdos
		fs-ext2
		netif-eth0
		netif-wvlan0
		etc.

	That way, a malicious user cannot cause a denial of service

by identifying one module with a loading bug (our kernels have 774 modules) and doing, "ifconfig <modulename>".

The extra work of doing the snprintf() into a buffer
before invoking request_module will resolve the buffer overrun issues too.

I would be happy to assist in coding this up. The 50 lines of
text that I have written in this email probably only translate into 20 lines of code.

Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[email protected]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America

fax +1 408 261-6631 "Free Software For The Rest Of Us."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 4 lines · Adam J. Richter
Quoted 2 lines

The only secure fix I can see is to add SAFEMODE=1 to modprobe's environment and change exec_modprobe.

SAFEMODE may mean other things to other programs, so that

MOD_SAFEMODE.

Quoted 2 lines

It would be much better to just add a command line option
to modprobe that request_module() would cause it treat the following

Changing the command line is not an option. Kernel 2.2 still runs with modutils 2.1.121, changing the request_module command line would break people using modutils 2.1.121 and force them to upgrade, AC would kill me. I needed a mechanism that would work with modutils 2.3 but have no effect on modutils 2.1.121, remember that 2.1.121 does not have this security exposure. It also had to work on 2.2 kernels because many people are using moditils 2.3 on 2.2 kernels. SGI ship a 2.2 kernel with devfs for their big machines, that needs modutils 2.3.

Quoted 8 lines

Another possible approach would be to create a separate
/sbin/safe_modprobe. modprobe already behaves differently based on whether argv[0] ends in "modprobe", "insmod", "depmod", or "rmmod". So this would be in keeping with that convention. It would also be trivial to retrofit old systems. Just have some system boot script do:

echo /sbin/safe_modprobe > /proc/sys/kernel/modprobe

I thought about that but it assumes that users will add that line to their scripts - not guaranteed. The fix needed a change that would automatically detect that safe mode was required and not rely on manual intervention. Especially with 30+ Linux distributions out there.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/