kernel-ark/net/ipv6
Vasiliy Kulikov 8909c9ad8f net: don't allow CAP_NET_ADMIN to load non-netdev kernel modules
Since a8f80e8ff9 any process with
CAP_NET_ADMIN may load any module from /lib/modules/.  This doesn't mean
that CAP_NET_ADMIN is a superset of CAP_SYS_MODULE as modules are
limited to /lib/modules/**.  However, CAP_NET_ADMIN capability shouldn't
allow anybody load any module not related to networking.

This patch restricts an ability of autoloading modules to netdev modules
with explicit aliases.  This fixes CVE-2011-1019.

Arnd Bergmann suggested to leave untouched the old pre-v2.6.32 behavior
of loading netdev modules by name (without any prefix) for processes
with CAP_SYS_MODULE to maintain the compatibility with network scripts
that use autoloading netdev modules by aliases like "eth0", "wlan0".

Currently there are only three users of the feature in the upstream
kernel: ipip, ip_gre and sit.

    root@albatros:~# capsh --drop=$(seq -s, 0 11),$(seq -s, 13 34) --
    root@albatros:~# grep Cap /proc/$$/status
    CapInh:	0000000000000000
    CapPrm:	fffffff800001000
    CapEff:	fffffff800001000
    CapBnd:	fffffff800001000
    root@albatros:~# modprobe xfs
    FATAL: Error inserting xfs
    (/lib/modules/2.6.38-rc6-00001-g2bf4ca3/kernel/fs/xfs/xfs.ko): Operation not permitted
    root@albatros:~# lsmod | grep xfs
    root@albatros:~# ifconfig xfs
    xfs: error fetching interface information: Device not found
    root@albatros:~# lsmod | grep xfs
    root@albatros:~# lsmod | grep sit
    root@albatros:~# ifconfig sit
    sit: error fetching interface information: Device not found
    root@albatros:~# lsmod | grep sit
    root@albatros:~# ifconfig sit0
    sit0      Link encap:IPv6-in-IPv4
	      NOARP  MTU:1480  Metric:1

    root@albatros:~# lsmod | grep sit
    sit                    10457  0
    tunnel4                 2957  1 sit

For CAP_SYS_MODULE module loading is still relaxed:

    root@albatros:~# grep Cap /proc/$$/status
    CapInh:	0000000000000000
    CapPrm:	ffffffffffffffff
    CapEff:	ffffffffffffffff
    CapBnd:	ffffffffffffffff
    root@albatros:~# ifconfig xfs
    xfs: error fetching interface information: Device not found
    root@albatros:~# lsmod | grep xfs
    xfs                   745319  0

Reference: https://lkml.org/lkml/2011/2/24/203

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Kees Cook <kees.cook@canonical.com>
Signed-off-by: James Morris <jmorris@namei.org>
2011-03-10 10:25:19 +11:00
..
netfilter netfilter: ip6t_LOG: fix a flaw in printing the MAC 2011-02-17 16:23:40 +01:00
addrconf_core.c
addrconf.c ipv6: Revert 'administrative down' address handling changes. 2011-01-25 12:49:08 -08:00
addrlabel.c
af_inet6.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2011-01-13 10:05:56 -08:00
ah6.c ah: reload pointers to skb data after calling skb_cow_data() 2011-01-11 14:03:10 -08:00
anycast.c
datagram.c
esp6.c xfrm: Traffic Flow Confidentiality for IPv6 ESP 2010-12-10 14:43:59 -08:00
exthdrs_core.c
exthdrs.c
fib6_rules.c
icmp.c
inet6_connection_sock.c tcp: disallow bind() to reuse addr/port 2011-01-11 14:03:07 -08:00
inet6_hashtables.c
ip6_fib.c
ip6_flowlabel.c
ip6_input.c
ip6_output.c inet6: prevent network storms caused by linux IPv6 routers 2011-01-12 18:51:55 -08:00
ip6_tunnel.c Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2010-12-08 13:47:38 -08:00
ip6mr.c net: Provide compat support for SIOCGETMIFCNT_IN6 and SIOCGETSGCNT_IN6. 2011-02-03 18:05:29 -08:00
ipcomp6.c
ipv6_sockglue.c
Kconfig
Makefile
mcast.c ipv6: mcast: RCU conversion 2010-11-24 11:16:42 -08:00
mip6.c
ndisc.c net: Abstract away all dst_entry metrics accesses. 2010-12-09 10:46:36 -08:00
netfilter.c net: use the macros defined for the members of flowi 2010-11-17 12:27:45 -08:00
proc.c
protocol.c
raw.c net: Provide compat support for SIOCGETMIFCNT_IN6 and SIOCGETSGCNT_IN6. 2011-02-03 18:05:29 -08:00
reassembly.c ipv6: Prepare the tree for un-inlined jhash. 2010-11-28 11:26:21 -08:00
route.c sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush 2011-02-25 11:01:56 -08:00
sit.c net: don't allow CAP_NET_ADMIN to load non-netdev kernel modules 2011-03-10 10:25:19 +11:00
syncookies.c
sysctl_net_ipv6.c net: Fix ipv6 neighbour unregister_sysctl_table warning 2011-01-31 20:54:17 -08:00
tcp_ipv6.c net: Abstract default ADVMSS behind an accessor. 2010-12-13 12:52:14 -08:00
tunnel6.c
udp_impl.h
udp.c Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2010-12-17 12:27:22 -08:00
udplite.c net: fix nulls list corruptions in sk_prot_alloc 2010-12-16 14:26:56 -08:00
xfrm6_input.c
xfrm6_mode_beet.c
xfrm6_mode_ro.c
xfrm6_mode_transport.c
xfrm6_mode_tunnel.c ipv6: Use ip6_dst_hoplimit() instead of direct dst_metric() calls. 2010-12-12 21:14:46 -08:00
xfrm6_output.c ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed. 2010-12-19 20:22:23 -08:00
xfrm6_policy.c xfrm6: Don't forget to propagate peer into ipsec route. 2011-01-26 13:41:03 -08:00
xfrm6_state.c
xfrm6_tunnel.c