diff options
| author | Josef Bacik <josef@toxicpanda.com> | 2026-10-17 23:09:41 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-10-18 00:36:43 +0000 |
| commit | f99351272933ba2e1221484a5e53b7a5d2c035f0 (patch) | |
| tree | 1d2a3e31e16bd005d0a0060149d2e5a734f645a6 /tools/perf/scripts/python | |
| parent | 6aff0129f327b159c86a54e6bea64a027630ff6b (diff) | |
bpf, cpumap: Hold the device of frames in the queue
A frame that is redirected to another CPU waits in the queue of the cpumap
entry with a plain pointer to the device it came from, and an skb from
generic XDP with skb->dev. Nothing keeps that device. Closing and
unregistering it waits for its NAPI and for RCU, but not for the kthread
of the entry. If the kthread is late by more than that, since its CPU is
busy with something of a higher priority, it builds skbs for a device that
has been freed and hands them to the stack:
BUG: KASAN: use-after-free in dev_gro_receive+0x1f51/0x2b30
Read of size 8 at addr ffff88800a7340b0 by task cpumap/1/map:1/54
Take a reference to the device for each entry of the queue. The kthread
cannot drop it at the end of the batch, since its GRO node may keep the skb
for longer. Let it note the devices and drop the references behind a full
GRO flush, which it does whenever the queue is empty, and from now on also
when it has noted about 2048 of them.
A device whose frames are stuck in a queue is now unregistered only when
the kthread has got to them. RTNL is not held meanwhile, but if the device
goes with its network namespace, the cleanup of all namespaces waits.
Fixes: 1c601d829ab0 ("bpf: cpumap xdp_buff to skb conversion and allocation")
Fixes: 11941f8a8536 ("bpf: cpumap: Implement generic cpumap")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261017230950.802052-8-alexei.starovoitov@gmail.com
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
