All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] mlxsw: spectrum_router: Fix NULL pointer dereference
@ 2017-06-28  6:03 Ido Schimmel
  2017-06-29 17:00 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Ido Schimmel @ 2017-06-28  6:03 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, petrm, mlxsw, Ido Schimmel

In case a VLAN device is enslaved to a bridge we shouldn't create a
router interface (RIF) for it when it's configured with an IP address.
This is already handled by the driver for other types of netdevs, such
as physical ports and LAG devices.

If this IP address is then removed and the interface is subsequently
unlinked from the bridge, a NULL pointer dereference can happen, as the
original 802.1d FID was replaced with an rFID which was then deleted.

To reproduce:
$ ip link set dev enp3s0np9 up
$ ip link add name enp3s0np9.111 link enp3s0np9 type vlan id 111
$ ip link set dev enp3s0np9.111 up
$ ip link add name br0 type bridge
$ ip link set dev br0 up
$ ip link set enp3s0np9.111 master br0
$ ip address add dev enp3s0np9.111 192.168.0.1/24
$ ip address del dev enp3s0np9.111 192.168.0.1/24
$ ip link set dev enp3s0np9.111 nomaster

Fixes: 99724c18fc66 ("mlxsw: spectrum: Introduce support for router interfaces")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reported-by: Petr Machata <petrm@mellanox.com>
Tested-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
---
Dave, please consider this patch for 4.9.y and 4.11.y. Note that it
won't apply cleanly as I moved the function from spectrum.c to
spectrum_router.c in 4.12. I can do the backport myself and post it to
netdev after the patch gets to mainline.

Thanks
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 9f89c41..0744452 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -3334,6 +3334,9 @@ static int mlxsw_sp_inetaddr_vlan_event(struct net_device *vlan_dev,
 	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(vlan_dev);
 	u16 vid = vlan_dev_vlan_id(vlan_dev);
 
+	if (netif_is_bridge_port(vlan_dev))
+		return 0;
+
 	if (mlxsw_sp_port_dev_check(real_dev))
 		return mlxsw_sp_inetaddr_vport_event(vlan_dev, real_dev, event,
 						     vid);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] mlxsw: spectrum_router: Fix NULL pointer dereference
  2017-06-28  6:03 [PATCH net] mlxsw: spectrum_router: Fix NULL pointer dereference Ido Schimmel
@ 2017-06-29 17:00 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-06-29 17:00 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jiri, petrm, mlxsw

From: Ido Schimmel <idosch@mellanox.com>
Date: Wed, 28 Jun 2017 09:03:12 +0300

> In case a VLAN device is enslaved to a bridge we shouldn't create a
> router interface (RIF) for it when it's configured with an IP address.
> This is already handled by the driver for other types of netdevs, such
> as physical ports and LAG devices.
> 
> If this IP address is then removed and the interface is subsequently
> unlinked from the bridge, a NULL pointer dereference can happen, as the
> original 802.1d FID was replaced with an rFID which was then deleted.
> 
> To reproduce:
> $ ip link set dev enp3s0np9 up
> $ ip link add name enp3s0np9.111 link enp3s0np9 type vlan id 111
> $ ip link set dev enp3s0np9.111 up
> $ ip link add name br0 type bridge
> $ ip link set dev br0 up
> $ ip link set enp3s0np9.111 master br0
> $ ip address add dev enp3s0np9.111 192.168.0.1/24
> $ ip address del dev enp3s0np9.111 192.168.0.1/24
> $ ip link set dev enp3s0np9.111 nomaster
> 
> Fixes: 99724c18fc66 ("mlxsw: spectrum: Introduce support for router interfaces")
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> Reported-by: Petr Machata <petrm@mellanox.com>
> Tested-by: Petr Machata <petrm@mellanox.com>
> Reviewed-by: Petr Machata <petrm@mellanox.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-29 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28  6:03 [PATCH net] mlxsw: spectrum_router: Fix NULL pointer dereference Ido Schimmel
2017-06-29 17:00 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.