]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: Add netdev all_adj_list refcnt propagation to fix panic
authorAndrew Collins <acollins@cradlepoint.com>
Mon, 3 Oct 2016 19:43:02 +0000 (13:43 -0600)
committerJiri Slaby <jslaby@suse.cz>
Mon, 28 Nov 2016 21:22:07 +0000 (22:22 +0100)
commita6109221deb9bf08efe73f258b7d7f8aa90db5d0
tree54af416cf0d214cfd4f1bb856988e5941b0b74bd
parent83d83b52245e623d53e7b766e23fc43bf80e77eb
net: Add netdev all_adj_list refcnt propagation to fix panic

[ Upstream commit 93409033ae653f1c9a949202fb537ab095b2092f ]

This is a respin of a patch to fix a relatively easily reproducible kernel
panic related to the all_adj_list handling for netdevs in recent kernels.

The following sequence of commands will reproduce the issue:

ip link add link eth0 name eth0.100 type vlan id 100
ip link add link eth0 name eth0.200 type vlan id 200
ip link add name testbr type bridge
ip link set eth0.100 master testbr
ip link set eth0.200 master testbr
ip link add link testbr mac0 type macvlan
ip link delete dev testbr

This creates an upper/lower tree of (excuse the poor ASCII art):

            /---eth0.100-eth0
mac0-testbr-
            \---eth0.200-eth0

When testbr is deleted, the all_adj_lists are walked, and eth0 is deleted twice from
the mac0 list. Unfortunately, during setup in __netdev_upper_dev_link, only one
reference to eth0 is added, so this results in a panic.

This change adds reference count propagation so things are handled properly.

Matthias Schiffer reported a similar crash in batman-adv:

https://github.com/freifunk-gluon/gluon/issues/680
https://www.open-mesh.org/issues/247

which this patch also seems to resolve.

[js] 3.12 does not have lists yet.

Signed-off-by: Andrew Collins <acollins@cradlepoint.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
net/core/dev.c