net/tap: fix interrupt callback crash after failed start
PATCH 1/1 net/tap: fix interrupt callback crash after failed start
After moving a tap linux net device to a different namespace, tap_link_set_up fails with an -ENODEV error. Indeed it relies on an ioctl call using the interface name as argument:
/* with ifr->ifrn_name = "dtapX" */ ioctl(pmd->ioctl_sock, SIOCGIFFLAGS, ifr)
This causes rte_eth_dev_stop() to do nothing since the device is not seen as started. And then, when removing the device, the interrupt callbacks are left there.
If they are invoked, they will be so with a "freed" device pointer:
Thread 2 "dpdk-intr" hit Breakpoint 1, tap_dev_intr_handler
at ../drivers/net/tap/rte_eth_tap.c:1689
1689 struct pmd_internals *pmd = dev->data->dev_private;
(gdb) p *dev
$2 = {
...
data = 0x0,
...
state = RTE_ETH_DEV_UNUSED,
security_ctx = 0x0
}
This causes a crash when dereferencing the data pointer.
When tap_link_set_up fails, ensure to unregister the interrupt callbacks that were just reinstalled.
--- drivers/net/tap/rte_eth_tap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/tap/rte_eth_tap.c +3 -1
@@ -889,8 +889,10 @@ tap_dev_start(struct rte_eth_dev *dev)return err; err =tap_link_set_up (dev); -if (err) +if (err) { +tap_intr_handle_set (dev,0 );return err; + }for (i =0 ; i < dev->data->nb_tx_queues; i++) dev->data->tx_queue_state[i] =RTE_ETH_QUEUE_STATE_STARTED ;
Signature · 1 line
2.51.0
Stephen Hemminger
AppliedQuoted 27 lines · On Fri, 17 Oct 2025 14:19:47 +0200 Robin Jarry <[email protected]> wrote:
After moving a tap linux net device to a different namespace,
tap_link_set_upfails with an-ENODEVerror. Indeed it relies on an ioctl call using the interface name as argument:/* with ifr->ifrn_name = "dtapX" */ ioctl(pmd->ioctl_sock, SIOCGIFFLAGS, ifr)This causes
rte_eth_dev_stop()to do nothing since the device is not seen as started. And then, when removing the device, the interrupt callbacks are left there.If they are invoked, they will be so with a "freed" device pointer:
Thread 2 "dpdk-intr" hit Breakpoint 1,
tap_dev_intr_handlerat ../drivers/net/tap/rte_eth_tap.c:16891689 struct
pmd_internals*pmd =dev->data->dev_private;
(gdb) p *dev
$2 = {
...
data =0x0,
...
state =RTE_ETH_DEV_UNUSED,
security_ctx=0x0
}This causes a crash when dereferencing the data pointer.
Quoted 7 lines
When
tap_link_set_upfails, ensure to unregister the interrupt callbacks that were just reinstalled.Fixes c0bddd3a057f ("net/tap: add link status notification")Signed-off-by Robin Jarry <[email protected]>
Queued to next-net
This email is triggering a rerun of testing at the DPDK Community Lab for this patchseries.
Recheck-request: iol-intel-Functional