* [PATCH] net: garp: reload skb header pointers after pskb_may_pull()
@ 2026-06-04 14:19 David Carlier
2026-06-09 2:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: David Carlier @ 2026-06-04 14:19 UTC (permalink / raw)
To: netdev
Cc: David Carlier, Claude, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Kees Cook,
Thomas Gleixner, Yizhou Zhao, Ingo Molnar, linux-kernel
garp_pdu_parse_attr() keeps a pointer into the skb linear area across
pskb_may_pull(skb, ga->len), and garp_pdu_parse_msg() dereferences gm
on every loop iteration even though the nested parse may pull again.
pskb_may_pull() can reallocate the skb head, which would leave those
pointers stale.
This is not reachable today: GARP PDUs arrive via the 802.2 LLC SAP
path, where llc_fixup_skb() already pulls and trims the whole payload
into the linear area, so the inner pulls never reallocate. Reload ga
after the pull and snapshot gm->attrtype into a local anyway, to harden
the parser and match the skb_header_pointer() discipline used by mrp.c.
No functional change.
Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: David Carlier <devnexen@gmail.com>
---
net/802/garp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/802/garp.c b/net/802/garp.c
index c7a39f298ad6..56b934ec1aae 100644
--- a/net/802/garp.c
+++ b/net/802/garp.c
@@ -452,6 +452,7 @@ static int garp_pdu_parse_attr(struct garp_applicant *app, struct sk_buff *skb,
if (!pskb_may_pull(skb, ga->len))
return -1;
+ ga = (struct garp_attr_hdr *)skb->data;
skb_pull(skb, ga->len);
dlen = ga->len - sizeof(*ga);
@@ -492,6 +493,7 @@ static int garp_pdu_parse_attr(struct garp_applicant *app, struct sk_buff *skb,
static int garp_pdu_parse_msg(struct garp_applicant *app, struct sk_buff *skb)
{
const struct garp_msg_hdr *gm;
+ u8 attrtype;
if (!pskb_may_pull(skb, sizeof(*gm)))
return -1;
@@ -499,9 +501,10 @@ static int garp_pdu_parse_msg(struct garp_applicant *app, struct sk_buff *skb)
if (gm->attrtype == 0)
return -1;
skb_pull(skb, sizeof(*gm));
+ attrtype = gm->attrtype;
while (skb->len > 0) {
- if (garp_pdu_parse_attr(app, skb, gm->attrtype) < 0)
+ if (garp_pdu_parse_attr(app, skb, attrtype) < 0)
return -1;
if (garp_pdu_parse_end_mark(skb) < 0)
break;
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net: garp: reload skb header pointers after pskb_may_pull()
2026-06-04 14:19 [PATCH] net: garp: reload skb header pointers after pskb_may_pull() David Carlier
@ 2026-06-09 2:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-09 2:20 UTC (permalink / raw)
To: David CARLIER
Cc: netdev, noreply, davem, edumazet, kuba, pabeni, horms, kees,
tglx, zhaoyz24, mingo, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 4 Jun 2026 15:19:22 +0100 you wrote:
> garp_pdu_parse_attr() keeps a pointer into the skb linear area across
> pskb_may_pull(skb, ga->len), and garp_pdu_parse_msg() dereferences gm
> on every loop iteration even though the nested parse may pull again.
> pskb_may_pull() can reallocate the skb head, which would leave those
> pointers stale.
>
> This is not reachable today: GARP PDUs arrive via the 802.2 LLC SAP
> path, where llc_fixup_skb() already pulls and trims the whole payload
> into the linear area, so the inner pulls never reallocate. Reload ga
> after the pull and snapshot gm->attrtype into a local anyway, to harden
> the parser and match the skb_header_pointer() discipline used by mrp.c.
>
> [...]
Here is the summary with links:
- net: garp: reload skb header pointers after pskb_may_pull()
https://git.kernel.org/netdev/net-next/c/ab71cf79e2f8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-09 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-04 14:19 [PATCH] net: garp: reload skb header pointers after pskb_may_pull() David Carlier
2026-06-09 2:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
powered by JetHome