Re: [PATCH] don't allow CAP_NET_ADMIN to load non-netdev kernelmodules

From: Vasiliy Kulikov
Date: Sun Feb 27 2011 - 06:45:17 EST


David,

On Fri, Feb 25, 2011 at 11:16 -0800, David Miller wrote:
> From: Ben Hutchings <bhutchings@xxxxxxxxxxxxxx>
> Date: Fri, 25 Feb 2011 19:07:59 +0000
>
> > You realise that module loading doesn't actually run in the context of
> > request_module(), right?
>
> Why is that a barrier? We could simply pass a capability mask into
> request_module if necessary.
>
> It's an implementation detail, and not a deterrant to my suggested
> scheme.

Let's discuss your scheme. AFAIU, you suggest to change:


1. a) request_module("%s", devname) =>
request_module_with_caps(CAP_NET_ADMIN, "%s", devname)

b) call_usermodehelper() => call_usermodehelper_with_caps()

c) add some bits/sections into kernel module image indicating that
this module is safe to be loaded via CAP_NET_ADMIN

d) run modprobe with CAP_NET_ADMIN only

e) in load_module() check whether (the process has CAP_SYS_MODULE) or
(the process has CAP_NET_ADMIN and bit SAFE_NET_MODULE is raised in
the module image)

This obviously doesn't work - the kernel is not able to verify whether
the bit/section is not malformed by user with CAP_NET_ADMIN.


-OR-


1. a) request_module("%s", devname) => request_module_with_argument("--netdev", "%s", devname)

b) patch modprobe to add "--netmodule-only" argument (or bitmask,
whatever), this would indicate that only net/** modules may be loaded.

Then the things are still broken - a user has to update modprobe
together with the kernel, otherwise the updated kernel would call
"modprobe" with unsupported argument and even "sit0" wouldn't work.


Additionally this touches module loading process, which is not buggy.


Or you propose something else besides these 2 ways? Please clarify.


Thanks,

--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/