[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTikmtKksP6o1hecf0=ZnRv0j4+_Q326UEG8ss16k@mail.gmail.com>
Date: Fri, 25 Feb 2011 21:59:50 +0100
From: Michał Mirosław <mirqus@...il.com>
To: Ben Hutchings <bhutchings@...arflare.com>
Cc: David Miller <davem@...emloft.net>, segoon@...nwall.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
kuznet@....inr.ac.ru, pekkas@...core.fi, jmorris@...ei.org,
yoshfuji@...ux-ipv6.org, kaber@...sh.net, eric.dumazet@...il.com,
therbert@...gle.com, xiaosuo@...il.com, jesse@...ira.com,
kees.cook@...onical.com, eugene@...hat.com,
dan.j.rosenberg@...il.com, akpm@...ux-foundation.org
Subject: Re: [PATCH] don't allow CAP_NET_ADMIN to load non-netdev kernel modules
2011/2/25 Ben Hutchings <bhutchings@...arflare.com>:
> I bet something like this (plus Vasiliy's changes to static module
> aliases) would cover 99.9% of legitimate uses of this feature:
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 54aaca6..0d09baa 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1120,8 +1120,20 @@ void dev_load(struct net *net, const char *name)
> dev = dev_get_by_name_rcu(net, name);
> rcu_read_unlock();
>
> - if (!dev && capable(CAP_NET_ADMIN))
> - request_module("%s", name);
> + if (!dev && capable(CAP_NET_ADMIN)) {
> + /* Check whether the name looks like one that a net
> + * driver will generate initially. If not, require a
> + * module alias with a suitable prefix, so that this
> + * can't be used to load arbitrary modules.
> + */
> + if ((strncmp(name, "eth", 3) == 0 &&
> + isdigit((unsigned char)name[3])) ||
> + (strncmp(name, "wlan", 4) == 0 &&
> + isdigit((unsigned char)name[4])))
> + request_module("%s", name);
> + else
> + request_module("netdev-%s", name);
> + }
> }
> EXPORT_SYMBOL(dev_load);
>
This might be better as:
if (request_module("netdev-%s", name))
... fallback
Then after some years the fallback could be removed if announced properly.
Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists