Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Qihang <q.h.hack.winter@gmail.com>,  netdev@vger.kernel.org
Cc: willemdebruijn.kernel@gmail.com,  daniel.zahka@gmail.com,
	 davem@davemloft.net,  edumazet@google.com,  kuba@kernel.org,
	 pabeni@redhat.com,  horms@kernel.org,  stable@vger.kernel.org,
	 Qihang <q.h.hack.winter@gmail.com>
Subject: Re: [PATCH net v3 1/2] packet: use consistent hard_header_len in non-ring send paths
Date: Tue, 28 Jul 2026 16:25:36 -0400	[thread overview]
Message-ID: <willemdebruijn.kernel.2edc77d9c7459@gmail.com> (raw)
In-Reply-To: <20260728031345.49562-2-q.h.hack.winter@gmail.com>

Qihang wrote:
> packet_snd() reads dev->hard_header_len multiple times while allocating
> and constructing an skb. Device reconfiguration can change this value
> concurrently, for example through bonding device type changes.
> 
> For SOCK_RAW, packet_snd() can save a larger value in reserve and later
> allocate headroom using a smaller value. Moving skb->data back by reserve
> then places it before skb->head, and the following copy from userspace can
> attempt an out-of-bounds write.
> 
> packet_sendmsg_spkt() has the same issue because it calculates its
> reservation and header offset from separate reads before dropping the RCU
> read lock to allocate the skb.
> 
> Add LL_RESERVED_SPACE_EX() for callers that already saved a header length.
> Read hard_header_len once in packet_snd() and use it for allocation and
> construction. In packet_sendmsg_spkt(), preserve the allocation-time value
> through the device lookup retry.
> 
> The separate SOCK_DGRAM consistency problem between hard_header_len and
> header_ops->create is not addressed here.
> 
> Fixes: b84bbaf7a6c8 ("packet: in packet_snd start writing at link layer allocation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qihang <q.h.hack.winter@gmail.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

New revisions should not be sent as a reply to an existing thread.

  reply	other threads:[~2026-07-28 20:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  8:49 [PATCH net] packet: use a consistent hard_header_len in send paths Qihang
2026-07-21 16:01 ` Daniel Zahka
2026-07-22 14:26   ` Willem de Bruijn
2026-07-24  3:36     ` Qihang
2026-07-25  7:39       ` Willem de Bruijn
2026-07-26  9:21 ` [PATCH net v2] packet: use consistent header lengths in raw " Qihang
2026-07-26 15:21   ` Willem de Bruijn
2026-07-28  3:10   ` [PATCH net v3 0/2] packet: use consistent hard_header_len in " Qihang
2026-07-28  3:13   ` Qihang
2026-07-28  3:13     ` [PATCH net v3 1/2] packet: use consistent hard_header_len in non-ring " Qihang
2026-07-28 20:25       ` Willem de Bruijn [this message]
2026-07-28  3:13     ` [PATCH net v3 2/2] packet: use consistent hard_header_len in TX_RING send path Qihang
2026-07-28 20:26       ` Willem de Bruijn

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=willemdebruijn.kernel.2edc77d9c7459@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=q.h.hack.winter@gmail.com \
    --cc=stable@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox