All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <hangbin.liu@linux.dev>
To: Sanghyun Park <sanghyun.park.cnu@gmail.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	David Stevens <dlstevens@us.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] vxlan: use one headroom snapshot for neighbour replies
Date: Sun, 20 Sep 2026 10:56:33 +0800	[thread overview]
Message-ID: <aq9LYXO9RTt3OXW9@fedora> (raw)
In-Reply-To: <20260918032842.502409-2-sanghyun.park.cnu@gmail.com>

Hi Sanghyun,
On Fri, Sep 18, 2026 at 12:26:58PM +0900, 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.
> 
> 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 and use that value for both allocation and
> reservation.

What if `vxlan_changelink()` extends the link headroom and we need a much
larger headroom, yet we only allocate a small skb from snapshot?

Thanks
Hangbin

> 
> Fixes: 4b29dba9c085 ("vxlan: fix nonfunctional neigh_reduce()")
> Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com>
> ---
> v2:
>   - Improve the v1 changelog
> v1: https://lore.kernel.org/r/20260831054614.2069896-2-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 c1d54339fa2b..3390e341d1e5 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -1958,13 +1958,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)
> @@ -1972,7 +1974,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

  reply	other threads:[~2026-09-20  2:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  3:26 [PATCH net v2] vxlan: use one headroom snapshot for neighbour replies Sanghyun Park
2026-09-20  2:56 ` Hangbin Liu [this message]
2026-09-24  2:50 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aq9LYXO9RTt3OXW9@fedora \
    --to=hangbin.liu@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dlstevens@us.ibm.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sanghyun.park.cnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.