Commit 81b1d548 authored by Lin Ma's avatar Lin Ma Committed by Jakub Kicinski

hamradio: remove needs_free_netdev to avoid UAF

The former patch "defer 6pack kfree after unregister_netdev" reorders
the kfree of two buffer after the unregister_netdev to prevent the race
condition. It also adds free_netdev() function in sixpack_close(), which
is a direct copy from the similar code in mkiss_close().

However, in sixpack driver, the flag needs_free_netdev is set to true in
sp_setup(), hence the unregister_netdev() will free the netdev
automatically. Therefore, as the sp is netdev_priv, use-after-free
occurs.

This patch removes the needs_free_netdev = true and just let the
free_netdev to finish this deallocation task.

Fixes: 0b911192 ("hamradio: defer 6pack kfree after unregister_netdev")
Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
Link: https://lore.kernel.org/r/20211111141402.7551-1-linma@zju.edu.cnSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 66f4beaa
...@@ -306,7 +306,6 @@ static void sp_setup(struct net_device *dev) ...@@ -306,7 +306,6 @@ static void sp_setup(struct net_device *dev)
{ {
/* Finish setting up the DEVICE info. */ /* Finish setting up the DEVICE info. */
dev->netdev_ops = &sp_netdev_ops; dev->netdev_ops = &sp_netdev_ops;
dev->needs_free_netdev = true;
dev->mtu = SIXP_MTU; dev->mtu = SIXP_MTU;
dev->hard_header_len = AX25_MAX_HEADER_LEN; dev->hard_header_len = AX25_MAX_HEADER_LEN;
dev->header_ops = &ax25_header_ops; dev->header_ops = &ax25_header_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment