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,  willemb@google.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 Tang <q.h.hack.winter@gmail.com>
Subject: Re: [PATCH net v6 1/3] net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header
Date: Tue, 04 Aug 2026 08:16:35 -0400	[thread overview]
Message-ID: <willemdebruijn.kernel.1d1da452d95b8@gmail.com> (raw)
In-Reply-To: <20260804090016.33353-2-q.h.hack.winter@gmail.com>

Qihang wrote:
> From: Qihang Tang <q.h.hack.winter@gmail.com>
> 
> dev_validate_header() reads dev->hard_header_len directly when
> zero-padding short link layer headers for CAP_SYS_RAWIO holders:
> 
>     if (capable(CAP_SYS_RAWIO)) {
>         memset(ll_header + len, 0, dev->hard_header_len - len);
>         return true;
>     }
> 
> Packet send paths call dev_validate_header() on skbs whose headroom was
> allocated from an earlier hard_header_len read. If the device is
> reconfigured so that dev->hard_header_len increases before validation,
> the memset writes past the reserved buffer, an out-of-bounds write.
> 
> This out-of-bounds write is masked in some SOCK_RAW paths today because
> the same concurrent increase can first make skb_push() exceed the
> reserved headroom and trigger skb_under_panic(). Remove the zero-padding
> branch before making those hard_header_len reads consistent, so the
> snapshot fixes do not turn a loud panic into a silent overwrite.
> 
> This path is only reached for variable length L2 protocols, where
> len < hard_header_len but len >= min_header_len. No remaining in-tree
> variable length L2 protocol implements header_ops->validate, and the
> CAP_SYS_RAWIO bypass that zero-pads and accepts short headers has no
> real value beyond allowing testing of intentionally malformed input.
> 
> Drop the CAP_SYS_RAWIO branch. The remaining reads of
> dev->hard_header_len in dev_validate_header() are comparisons only and
> have no memory safety impact.
> 
> Suggested-by: Willem de Bruijn <willemb@google.com>
> Fixes: 2793a23aacbd ("net: validate variable length ll headers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qihang Tang <q.h.hack.winter@gmail.com>

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

For future patches: don't send new revisions as replies to existing threads.

  reply	other threads:[~2026-08-04 12:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  8:29 [PATCH net v5 0/2] packet: use consistent hard_header_len in send paths Qihang
2026-07-30  8:29 ` [PATCH net v5 1/2] packet: use consistent hard_header_len in non-ring " Qihang
2026-07-30  8:29 ` [PATCH net v5 2/2] packet: use consistent hard_header_len in TX_RING send path Qihang
2026-07-30  9:22   ` Willem de Bruijn
2026-08-04  2:22     ` Jakub Kicinski
2026-08-04  3:04       ` Willem de Bruijn
2026-08-04 23:43         ` Jakub Kicinski
2026-08-04  9:00 ` [PATCH net v6 0/3] net: fix hard_header_len races in packet send paths Qihang
2026-08-04  9:00   ` [PATCH net v6 1/3] net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header Qihang
2026-08-04 12:16     ` Willem de Bruijn [this message]
2026-08-04 23:44       ` Jakub Kicinski
2026-08-04  9:32 ` [PATCH net v6 2/3] packet: use consistent hard_header_len in non-ring send paths Qihang
2026-08-04  9:33 ` [PATCH net v6 3/3] packet: use consistent hard_header_len in TX_RING send path Qihang
  -- strict thread matches above, loose matches on Subject: below --
2026-08-05 12:57 [PATCH net v6 0/3] net: fix hard_header_len races in packet send paths Qihang
2026-08-05 12:57 ` [PATCH net v6 1/3] net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header Qihang
2026-08-06  3:07   ` 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.1d1da452d95b8@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 \
    --cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox