Commit ddf3067
port: unplug from graph before destroy
The port_rx node stores a direct pointer to its associated struct iface
in its context (ctx->iface). This pointer is set during graph
initialization and is used directly to access interface data without
going through iface_from_id().
When deleting a port interface, the previous sequence was:
1. gr_event_push(IFACE_PRE_REMOVE)
2. cleanup (status down, vrf decref, nexthop cleanup)
3. ifaces[iface->id] = NULL
4. rte_rcu_qsbr_synchronize()
5. gr_event_push(IFACE_REMOVE)
6. rte_free(iface)
This was not sufficient to prevent use-after-free. Even after setting
ifaces[id] to NULL and waiting for RCU sync, the port_rx node would
continue running and receiving packets while holding a stale pointer to
the freed iface memory. This was detected by libasan:
+ grcli interface del p0
...
DEBUG: GROUT: iface_event: iface event [0xacdc0003] PRE_REMOVE triggered for iface p0.
...
DEBUG: GROUT: iface_event: iface event [0xacdc0007] STATUS_DOWN triggered for iface p0.
DEBUG: GROUT: iface_event: iface event [0xacdc0004] REMOVE triggered for iface p0.
...
NOTICE: GROUT: [rx p0] 02:e3:ad:74:50:9b > 01:80:c2:00:00:02 / LACP active fast aggreg sync collect distrib, (pkt_len=124)
...
INFO: GROUT: iface_port_fini: port 0 destroyed
=================================================================
==72683==ERROR: AddressSanitizer: heap-use-after-free ...
READ of size 1 at 0x7f9764309b02 thread T0
lacp_input_cb ../modules/infra/control/lacp.c:42
control_queue_poll ../modules/infra/control/control_queue.c:52
event_base_loop (/lib/x86_64-linux-gnu/libevent_core-2.1.so.7+0x20fae)
main ../main/main.c:326
Fix this by subscribing to GR_EVENT_IFACE_PRE_REMOVE and calling
port_unplug() which disables the port queue mappings and reloads all
worker graphs, effectively removing the port_rx nodes for that port.
Fixes: 587d5e4 ("rx,tx: use one node per port queue")
Signed-off-by: Robin Jarry <rjarry@redhat.com>
Reviewed-by: Anthony Harivel <aharivel@redhat.com>
Reviewed-by: Maxime Leroy <maxime@leroys.fr>1 parent 393b14b commit ddf3067
3 files changed
+17
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
815 | 815 | | |
816 | 816 | | |
817 | 817 | | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
818 | 832 | | |
819 | 833 | | |
820 | 834 | | |
| 835 | + | |
821 | 836 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
0 commit comments