]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: validate skb->napi_id in RX tracepoints
authorKohei Enju <kohei@enjuk.jp>
Mon, 20 Apr 2026 10:54:23 +0000 (10:54 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Apr 2026 03:15:50 +0000 (20:15 -0700)
Since commit 2bd82484bb4c ("xps: fix xps for stacked devices"),
skb->napi_id shares storage with sender_cpu. RX tracepoints using
net_dev_rx_verbose_template read skb->napi_id directly and can therefore
report sender_cpu values as if they were NAPI IDs.

For example, on the loopback path this can report 1 as napi_id, where 1
comes from raw_smp_processor_id() + 1 in the XPS path:

  # bpftrace -e 'tracepoint:net:netif_rx_entry{ print(args->napi_id); }'
  # taskset -c 0 ping -c 1 ::1

Report only valid NAPI IDs in these tracepoints and use 0 otherwise.

Fixes: 2bd82484bb4c ("xps: fix xps for stacked devices")
Signed-off-by: Kohei Enju <kohei@enjuk.jp>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20260420105427.162816-1-kohei@enjuk.jp
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/trace/events/net.h

index fdd9ad474ce3ae080b7223d4b45e293cbc14d18d..dbc2c5598e35adfe0cc953231db91fcd6bbcb751 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/if_vlan.h>
 #include <linux/ip.h>
 #include <linux/tracepoint.h>
+#include <net/busy_poll.h>
 
 TRACE_EVENT(net_dev_start_xmit,
 
@@ -208,7 +209,8 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
        TP_fast_assign(
                __assign_str(name);
 #ifdef CONFIG_NET_RX_BUSY_POLL
-               __entry->napi_id = skb->napi_id;
+               __entry->napi_id = napi_id_valid(skb->napi_id) ?
+                                  skb->napi_id : 0;
 #else
                __entry->napi_id = 0;
 #endif