mctp: serial: Cancel pending work from ndo_uninit handler
Jeremy Kerr
maintainerPATCH 1/1 mctp: serial: Cancel pending work from ndo_uninit handler
We cannot do the cancel_work_sync from after the unregister_netdev, as the dev pointer is no longer valid, causing a uaf on ldisc unregister (or device close).
Instead, do the cancel_work_sync from the ndo_uninit op, where the dev still exists, but the queue has stopped.
--- drivers/net/mctp/mctp-serial.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/mctp/mctp-serial.c +8 -1
@@ -403,8 +403,16 @@ static void mctp_serial_tty_receive_buf(struct tty_struct *tty,mctp_serial_push (dev, c[i]); } +static void mctp_serial_uninit (struct net_device *ndev) +{ +struct mctp_serial *dev =netdev_priv (ndev); + +cancel_work_sync (&dev->tx_work); +} +static const struct net_device_ops mctp_serial_netdev_ops = { .ndo_start_xmit = mctp_serial_tx, + .ndo_uninit = mctp_serial_uninit, };static void mctp_serial_setup (struct net_device *ndev)
@@ -483,7 +491,6 @@ static void mctp_serial_close(struct tty_struct *tty)int idx = dev->idx;unregister_netdev (dev->netdev); -cancel_work_sync (&dev->tx_work);ida_free (&mctp_serial_ida, idx); }
Signature · 1 line
2.34.1
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 11 Feb 2022 09:15:52 +0800 you wrote:
We cannot do the
cancel_work_syncfrom after theunregister_netdev, as the dev pointer is no longer valid, causing a uaf on ldisc unregister (or device close).Instead, do the
cancel_work_syncfrom thendo_uninitop, where the dev still exists, but the queue has stopped.[...]
Here is the summary with links:
- [net] mctp: serial: Cancel pending work from ndo_uninit handler
https://git.kernel.org/netdev/net/c/6c342ce2239c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html