linux/net/hsr
Arvid Brodin 56b08fdcf6 net/hsr: Fix NULL pointer dereference and refcnt bugs when deleting a HSR interface.
To repeat:

$ sudo ip link del hsr0
BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
IP: [<ffffffff8187f495>] hsr_del_port+0x15/0xa0
etc...

Bug description:

As part of the hsr master device destruction, hsr_del_port() is called for each of
the hsr ports. At each such call, the master device is updated regarding features
and mtu. When the master device is freed before the slave interfaces, master will
be NULL in hsr_del_port(), which led to a NULL pointer dereference.

Additionally, dev_put() was called on the master device itself in hsr_del_port(),
causing a refcnt error.

A third bug in the same code path was that the rtnl lock was not taken before
hsr_del_port() was called as part of hsr_dev_destroy().

The reporter (Nicolas Dichtel) also said: "hsr_netdev_notify() supposes that the
port will always be available when the notification is for an hsr interface. It's
wrong. For example, netdev_wait_allrefs() may resend NETDEV_UNREGISTER.". As a
precaution against this, a check for port == NULL was added in hsr_dev_notify().

Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Fixes: 51f3c60531 ("net/hsr: Move slave init to hsr_slave.c.")
Signed-off-by: Arvid Brodin <arvid.brodin@alten.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-03-01 13:40:23 -05:00
..
hsr_device.c net/hsr: Fix NULL pointer dereference and refcnt bugs when deleting a HSR interface. 2015-03-01 13:40:23 -05:00
hsr_device.h net/hsr: Operstate handling cleanup. 2014-07-08 11:35:30 -07:00
hsr_forward.c net/hsr: Better frame dispatch 2014-07-08 11:35:31 -07:00
hsr_forward.h net/hsr: Better frame dispatch 2014-07-08 11:35:31 -07:00
hsr_framereg.c net/hsr: Remove left-over never-true conditional code. 2014-07-11 15:04:40 -07:00
hsr_framereg.h net/hsr: Better frame dispatch 2014-07-08 11:35:31 -07:00
hsr_main.c net/hsr: Fix NULL pointer dereference and refcnt bugs when deleting a HSR interface. 2015-03-01 13:40:23 -05:00
hsr_main.h net/hsr: Better frame dispatch 2014-07-08 11:35:31 -07:00
hsr_netlink.c net/hsr: Fix NULL pointer dereference on incomplete hsr_newlink() params. 2014-07-08 11:35:31 -07:00
hsr_netlink.h net/hsr: Use list_head (and rcu) instead of array for slave devices. 2014-07-08 11:35:31 -07:00
hsr_slave.c net/hsr: Fix NULL pointer dereference and refcnt bugs when deleting a HSR interface. 2015-03-01 13:40:23 -05:00
hsr_slave.h net/hsr: Better frame dispatch 2014-07-08 11:35:31 -07:00
Kconfig net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0) 2013-11-03 23:20:14 -05:00
Makefile net/hsr: Better frame dispatch 2014-07-08 11:35:31 -07:00