net: avoid prefetching NULL pointers
Subsystems (2)
PATCH 1/1 net: avoid prefetching NULL pointers
Aditya Gupta reported PowerPC crashes bisected to the blamed commit.
Apparently some platforms do not allow prefetch() on arbitrary pointers.
prefetch(next); prefetch(&next->priority); // CRASH when next == NULL
Only NULL seems to be supported, with specific handling in prefetch().
Add a conditional to avoid the two prefetches and the skb->next clearing for the last skb in the list.
--- net/core/dev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/core/dev.c +5 -3
@@ -4241,9 +4241,11 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,int count =0 ;llist_for_each_entry_safe (skb, next, ll_list, ll_node) { -prefetch (next); -prefetch (&next->priority); -skb_mark_not_on_list (skb); +if (next) { +prefetch (next); +prefetch (&next->priority); +skb_mark_not_on_list (skb); + } rc =dev_qdisc_enqueue (skb, q, &to_free, txq); count++; }
Signature · 1 line
2.52.0.313.g674ac2bdf7-goog
Quoted 12 lines · Eric Dumazet
Aditya Gupta reported PowerPC crashes bisected to the blamed commit.
Apparently some platforms do not allow
prefetch()on arbitrary pointers.prefetch(next); prefetch(&next->priority); // CRASH when next == NULLOnly NULL seems to be supported, with specific handling in
prefetch().Add a conditional to avoid the two prefetches and the
skb->nextclearing for the last skb in the list.
Quoted 7 lines
Fixes b2e9821cff6c ("net: prefech skb->priority in __dev_xmit_skb()")Reported-by Aditya Gupta <[email protected]>Closes https://lore.kernel.org/netdev/[email protected]/T/#mddc372b64ec5a3b181acc9ee3909110c391cc18a open hereSigned-off-by Eric Dumazet <[email protected]>--- net/core/dev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Thanks for the quick fix Eric.
It fixes the reported kernel bug, hence:
Thanks,
- Aditya G
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Thu, 18 Dec 2025 08:18:44 +0000 you wrote:
Aditya Gupta reported PowerPC crashes bisected to the blamed commit.
Apparently some platforms do not allow
prefetch()on arbitrary pointers.prefetch(next); prefetch(&next->priority); // CRASH when next == NULL[...]
Here is the summary with links:
- [net] net: avoid prefetching NULL pointers
https://git.kernel.org/netdev/net/c/c04de0c79534
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html