]> git.baikalelectronics.ru Git - kernel.git/commit
net: qualcomm: rmnet: Fix potential UAF when unregistering
authorSean Tranchetti <stranche@codeaurora.org>
Tue, 5 Nov 2019 00:54:22 +0000 (17:54 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Nov 2019 02:18:03 +0000 (18:18 -0800)
commit1b501fdd927dac2e0d895a7c1f373decdba9b92e
tree836ad1c82d1a2bbe550825ef8f89acb109977313
parent18870c70a56c903a9c46f1335dde27972828ed30
net: qualcomm: rmnet: Fix potential UAF when unregistering

During the exit/unregistration process of the RmNet driver, the function
rmnet_unregister_real_device() is called to handle freeing the driver's
internal state and removing the RX handler on the underlying physical
device. However, the order of operations this function performs is wrong
and can lead to a use after free of the rmnet_port structure.

Before calling netdev_rx_handler_unregister(), this port structure is
freed with kfree(). If packets are received on any RmNet devices before
synchronize_net() completes, they will attempt to use this already-freed
port structure when processing the packet. As such, before cleaning up any
other internal state, the RX handler must be unregistered in order to
guarantee that no further packets will arrive on the device.

Fixes: d1878d04ca05 ("drivers: net: ethernet: qualcomm: rmnet: Initial implementation")
Signed-off-by: Sean Tranchetti <stranche@codeaurora.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c