linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/4] make call_usermodehelper a bit more "safe"
@ 2016-12-14 18:50 Greg KH
  2016-12-14 18:50 ` [PATCH 1/4] kmod: make usermodehelper path a const string Greg KH
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Greg KH @ 2016-12-14 18:50 UTC (permalink / raw)
  To: kernel-hardening; +Cc: linux-kernel

Hi all,

Here's a proof-of-concept patch series that tries to work to address the
issue of call_usermodehelper being abused to have the kernel call any
userspace binary with full root permissions.

The issue is that if you end up getting write access to kernel memory,
if you change the string '/sbin/hotplug' to point to
'/home/hacked/my_binary', then the next uevent that the system makes
will call this binary instead of the "trusted" one.

It does this by moving the location of the binary to be in read-only
memory.  This works for a number of call_usermodehelper strings, as they
are specified at build or configuration time.  But, some subsystems have
the option to let userspace change the value at runtime, so those values
can't live in read-only memory.  To resolve this I've created a new
configuration option, CONFIG_READONLY_USERMODEHELPER to make those
options not able to be changed.

Yes, this changes existing functionality, but I'm willing to bet that
almost no one ever changes these binary locations, or if they do, they
can set them to the "correct" location at built time.

This all happens in the last patch of the series.  Note, I haven't
caught all places in the kernel that has these options, the messiest
being coredumps, which I haven't addressed yet, and is going to be a
pain.

This last patch is hacky, and I'm not really happy about it, so I'm
posting it here as an RFC to see what others think.

As a contrast, grsec does try to mitigate this same problem, but it does
so by looking at the location of the binary that is about to be run, and
only allowing a small whitelist of directories that are "allowed" to be
used.  That's a much simpler solution, but also feels hacky to me in a
way given that it's a whitelist and encompasses whole system directories
(i.e. /sbin/).  My patchset requires that each caller of
call_usermodehelper be audited, which is a pain, and will be needed to
be watched out for for new users, which also isn't any good.

So, anyone have any better ideas?  Is this approach worth it?  Or should
we just go down the "whitelist" path?

Note, the first 3 patches in this series will be submitted for inclusion
either way, as they are good cleanups, and change no functionality at
all, and resolve this issue automatically for some subsystems with no
downside.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2016-12-20 10:48 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 18:50 [RFC 0/4] make call_usermodehelper a bit more "safe" Greg KH
2016-12-14 18:50 ` [PATCH 1/4] kmod: make usermodehelper path a const string Greg KH
2016-12-14 18:50 ` [PATCH 2/4] drbd: rename "usermode_helper" to "drbd_usermode_helper" Greg KH
2016-12-14 18:50 ` [PATCH 3/4] Make static usermode helper binaries constant Greg KH
2016-12-14 19:11   ` [kernel-hardening] " Greg KH
2016-12-14 20:29   ` Rich Felker
2016-12-14 20:54     ` Greg KH
2016-12-15 17:54       ` Greg KH
2016-12-15 20:51         ` Daniel Micay
2016-12-15 21:18           ` Greg KH
2016-12-16  0:05             ` Daniel Micay
2016-12-16  0:14               ` Daniel Micay
2016-12-14 18:51 ` [RFC 4/4] Introduce CONFIG_READONLY_USERMODEHELPER Greg KH
2016-12-14 20:31   ` Kees Cook
2016-12-14 20:57     ` Greg KH
2016-12-14 19:25 ` [kernel-hardening] [RFC 0/4] make call_usermodehelper a bit more "safe" Mark Rutland
2016-12-14 20:16   ` Kees Cook
2016-12-14 21:28 ` Jason A. Donenfeld
2016-12-14 23:16   ` Greg Kroah-Hartman
2016-12-16  1:02 ` NeilBrown
2016-12-16 12:49   ` Greg KH
2016-12-19 13:34     ` Jiri Kosina
2016-12-20  9:27       ` Greg KH
2016-12-20 10:27         ` Jiri Kosina
2016-12-20 10:31           ` Jiri Kosina
2016-12-20 10:48             ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).