Message ID | 20220217014303.102986-1-duoming@zju.edu.cn (mailing list archive) |
---|---|
State | Accepted |
Commit | efe4186e6a1b54bf38b9e05450d43b0da1fd7739 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [V3] drivers: hamradio: 6pack: fix UAF bug caused by mod_timer() | expand |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Thu, 17 Feb 2022 09:43:03 +0800 you wrote: > When a 6pack device is detaching, the sixpack_close() will act to cleanup > necessary resources. Although del_timer_sync() in sixpack_close() > won't return if there is an active timer, one could use mod_timer() in > sp_xmit_on_air() to wake up timer again by calling userspace syscall such > as ax25_sendmsg(), ax25_connect() and ax25_ioctl(). > > This unexpected waked handler, sp_xmit_on_air(), realizes nothing about > the undergoing cleanup and may still call pty_write() to use driver layer > resources that have already been released. > > [...] Here is the summary with links: - [V3] drivers: hamradio: 6pack: fix UAF bug caused by mod_timer() https://git.kernel.org/netdev/net/c/efe4186e6a1b You are awesome, thank you!
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index b1fc153125d..45c3c4a1101 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c @@ -668,11 +668,11 @@ static void sixpack_close(struct tty_struct *tty) */ netif_stop_queue(sp->dev); + unregister_netdev(sp->dev); + del_timer_sync(&sp->tx_t); del_timer_sync(&sp->resync_t); - unregister_netdev(sp->dev); - /* Free all 6pack frame buffers after unreg. */ kfree(sp->rbuff); kfree(sp->xbuff);