Skip to content

Commit 6c342ce

Browse files
jk-ozlabskuba-moo
authored andcommitted
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. Fixes: 7bd9890 ("mctp: serial: cancel tx work on ldisc close") Reported-by: Luo Likang <[email protected]> Tested-by: Luo Likang <[email protected]> Signed-off-by: Jeremy Kerr <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6bb9681 commit 6c342ce

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/net/mctp/mctp-serial.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,16 @@ static void mctp_serial_tty_receive_buf(struct tty_struct *tty,
403403
mctp_serial_push(dev, c[i]);
404404
}
405405

406+
static void mctp_serial_uninit(struct net_device *ndev)
407+
{
408+
struct mctp_serial *dev = netdev_priv(ndev);
409+
410+
cancel_work_sync(&dev->tx_work);
411+
}
412+
406413
static const struct net_device_ops mctp_serial_netdev_ops = {
407414
.ndo_start_xmit = mctp_serial_tx,
415+
.ndo_uninit = mctp_serial_uninit,
408416
};
409417

410418
static void mctp_serial_setup(struct net_device *ndev)
@@ -483,7 +491,6 @@ static void mctp_serial_close(struct tty_struct *tty)
483491
int idx = dev->idx;
484492

485493
unregister_netdev(dev->netdev);
486-
cancel_work_sync(&dev->tx_work);
487494
ida_free(&mctp_serial_ida, idx);
488495
}
489496

0 commit comments

Comments
 (0)