* [PATCH net] phonet: fix use-after-free in can_respond()
@ 2026-11-25 22:16 Elkin Cruz
0 siblings, 0 replies; only message in thread
From: Elkin Cruz @ 2026-11-25 22:16 UTC (permalink / raw)
To: Remi Denis-Courmont, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Nathan Chancellor
Cc: Simon Horman, Nick Desaulniers, Bill Wendling, Justin Stitt,
netdev, llvm, Rémi Denis-Courmont, linux-kernel, irogers,
Elkin Cruz, stable
In can_respond(), ph is cached before pskb_may_pull(skb, 5). When
ph->pn_res == PN_PREFIX and pskb_may_pull() reallocates skb->head,
the check `if (ph->pn_res == PN_COMMGR)` dereferences the dangling ph
pointer before the code re-acquires ph = pn_hdr(skb).
Check for PN_COMMGR before calling pskb_may_pull() to avoid accessing
the potentially invalidated header pointer.
This issue was found while trying out new Clang static analysis checks for
kernel bug classes. The finding was triaged and fixed, and this commit
description was drafted with the help of AI, then verified by code
inspection and compile-tested against linux-next (not reproduced and not
runtime-tested on hardware).
Fixes: c3a90c788b74 ("Phonet: do not reply to indication reset packets")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---
net/phonet/af_phonet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index d89225d6bfd3..e70ade97bf17 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -294,10 +294,10 @@ static inline int can_respond(struct sk_buff *skb)
return 0;
ph = pn_hdr(skb);
- if (ph->pn_res == PN_PREFIX && !pskb_may_pull(skb, 5))
- return 0;
if (ph->pn_res == PN_COMMGR) /* indications */
return 0;
+ if (ph->pn_res == PN_PREFIX && !pskb_may_pull(skb, 5))
+ return 0;
ph = pn_hdr(skb); /* re-acquires the pointer */
pm = pn_msg(skb);
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 22:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 22:16 [PATCH net] phonet: fix use-after-free in can_respond() Elkin Cruz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox