Netdev List
 help / color / mirror / Atom feed
* [PATCH net] vxlan: use one headroom snapshot for neighbour replies
@ 2026-08-31  5:46 Sanghyun Park
  2026-09-01 10:10 ` Paolo Abeni
  0 siblings, 1 reply; 3+ messages in thread
From: Sanghyun Park @ 2026-08-31  5:46 UTC (permalink / raw)
  To: netdev
  Cc: Sanghyun Park, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, David Stevens, linux-kernel

vxlan_na_create() samples LL_RESERVED_SPACE() to size the reply skb and then
samples it again to reserve headroom. A concurrent vxlan_changelink() can
update needed_headroom between the two reads, creating a TOCTOU race. The
second value can exceed the allocation and make the Ethernet header write out
of bounds.

Snapshot the headroom once and use that value for both allocation and
reservation.

Fixes: 4b29dba9c085 ("vxlan: fix nonfunctional neigh_reduce()")
Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com>
---
 drivers/net/vxlan/vxlan_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 459f19f7071e..e5a92d30113c 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1947,13 +1947,15 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,
 	struct ipv6hdr *pip6;
 	u8 *daddr;
 	int na_olen = 8; /* opt hdr + ETH_ALEN for target */
+	int headroom;
 	int ns_olen;
 	int i, len;
 
 	if (dev == NULL || !pskb_may_pull(request, request->len))
 		return NULL;
 
-	len = LL_RESERVED_SPACE(dev) + sizeof(struct ipv6hdr) +
+	headroom = LL_RESERVED_SPACE(dev);
+	len = headroom + sizeof(struct ipv6hdr) +
 		sizeof(*na) + na_olen + dev->needed_tailroom;
 	reply = alloc_skb(len, GFP_ATOMIC);
 	if (reply == NULL)
@@ -1961,7 +1963,7 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,
 
 	reply->protocol = htons(ETH_P_IPV6);
 	reply->dev = dev;
-	skb_reserve(reply, LL_RESERVED_SPACE(request->dev));
+	skb_reserve(reply, headroom);
 	skb_push(reply, sizeof(struct ethhdr));
 	skb_reset_mac_header(reply);
 
-- 
2.48.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] vxlan: use one headroom snapshot for neighbour replies
  2026-08-31  5:46 [PATCH net] vxlan: use one headroom snapshot for neighbour replies Sanghyun Park
@ 2026-09-01 10:10 ` Paolo Abeni
  2026-09-02  6:59   ` Sanghyun Park
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Abeni @ 2026-09-01 10:10 UTC (permalink / raw)
  To: Sanghyun Park, netdev
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	David Stevens, linux-kernel

On 8/31/26 7:46 AM, Sanghyun Park wrote:
> vxlan_na_create() samples LL_RESERVED_SPACE() to size the reply skb and then
> samples it again to reserve headroom. A concurrent vxlan_changelink() can
> update needed_headroom between the two reads, creating a TOCTOU race. The
> second value can exceed the allocation and make the Ethernet header write out
> of bounds.
> 
> Snapshot the headroom once and use that value for both allocation and
> reservation.
> 
> Fixes: 4b29dba9c085 ("vxlan: fix nonfunctional neigh_reduce()")
> Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com>
The patch LGTM, but the changelog needs some improvements: if you have
can observe a splat on the unpatched kernel, please include it,
otherwise please explain whythe issue is not just a theoretical one.
Also please specify if some LLM has been used.

Thanks,

Paolo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] vxlan: use one headroom snapshot for neighbour replies
  2026-09-01 10:10 ` Paolo Abeni
@ 2026-09-02  6:59   ` Sanghyun Park
  0 siblings, 0 replies; 3+ messages in thread
From: Sanghyun Park @ 2026-09-02  6:59 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Sanghyun Park, netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, David Stevens, linux-kernel

Thanks for the review, Paolo.

> if you can observe a splat on the unpatched kernel, please include it,
> otherwise please explain why the issue is not just a theoretical one.

I thought it would make the changelog verbose by putting the evidences of the
bugs (some people like concise changelogs).

If you prefer splats in there, let me add some in v2.

It would be like:

```
/* vxlan_na_create() samples ... */

The race is reproducible on the unpatched kernel. It occurred when
vxlan_na_create() generated a neighbour reply while vxlan_changelink() changed
the link headroom. KASAN caught a four-byte write two bytes beyond a 704-byte
skbuff_small_head allocation.

/* Snapshot the headroom once ... */
```

JFYI, every patch I make is done only after I get real evidence :)

> Also please specify if some LLM has been used.

I used LLM assistance during bug discovery, analysis, etc, but try to review
with my eyes as much as I can.


Plz check the new paragraph of the changelog whether it is ok for v2.

Thanks,
Sanghyun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-02  7:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31  5:46 [PATCH net] vxlan: use one headroom snapshot for neighbour replies Sanghyun Park
2026-09-01 10:10 ` Paolo Abeni
2026-09-02  6:59   ` Sanghyun Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox