]> git.baikalelectronics.ru Git - kernel.git/commit
vxlan: test dev->flags & IFF_UP before calling netif_rx()
authorEric Dumazet <edumazet@google.com>
Thu, 7 Feb 2019 20:27:38 +0000 (12:27 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Feb 2019 20:39:51 +0000 (12:39 -0800)
commitf35333c1f0cf8d02319298cf588b8d04a75d3a58
tree83dc255e437ace38c17db611fd8052cb8db1dfd8
parent5c5735707c59e7b7e180227c9bdcf8f113206cc3
vxlan: test dev->flags & IFF_UP before calling netif_rx()

netif_rx() must be called under a strict contract.

At device dismantle phase, core networking clears IFF_UP
and flush_all_backlogs() is called after rcu grace period
to make sure no incoming packet might be in a cpu backlog
and still referencing the device.

Most drivers call netif_rx() from their interrupt handler,
and since the interrupts are disabled at device dismantle,
netif_rx() does not have to check dev->flags & IFF_UP

Virtual drivers do not have this guarantee, and must
therefore make the check themselves.

Otherwise we risk use-after-free and/or crashes.

Note this patch also fixes a small issue that came
with commit fa9e8d79aeee ("vxlan: fix a use after free
in vxlan_encap_bypass"), since the dev->stats.rx_dropped
change was done on the wrong device.

Fixes: 37f0daba9a3d ("vxlan: virtual extensible lan")
Fixes: fa9e8d79aeee ("vxlan: fix a use after free in vxlan_encap_bypass")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Petr Machata <petrm@mellanox.com>
Cc: Ido Schimmel <idosch@mellanox.com>
Cc: Roopa Prabhu <roopa@cumulusnetworks.com>
Cc: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/vxlan.c