From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Hui Peng" <benquike@gmail.com>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>
Cc: "Willem de Bruijn" <willemb@google.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>, <bpf@vger.kernel.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bpf: reject unset network_header for SKF_NET_OFF in cBPF load helper
Date: Sat, 19 Sep 2026 23:18:26 +0000 [thread overview]
Message-ID: <DLJODTPSL3IT.1LQ0SJ80PGO1M@gmail.com> (raw)
In-Reply-To: <20260919203517.2581484-1-benquike@gmail.com>
On Sat, Sep 19, 2026 at 08:35 PM Hui Peng <benquike@gmail.com> wrote:
> diff --git a/net/core/filter.c b/net/core/filter.c
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -231,8 +231,14 @@ static int bpf_skb_load_helper_convert_offset(const struct sk_buff *skb, int off
> if (likely(offset >= 0))
> return offset;
>
> - if (offset >= SKF_NET_OFF)
> + if (offset >= SKF_NET_OFF) {
> + if (skb_mac_header_was_set(skb) ?
> + skb->network_header < skb->mac_header :
> + (skb_network_offset(skb) < 0 ||
> + (!skb->protocol && !skb->network_header)))
> + return INT_MIN;
No. network_header == 0 is a valid value when there is no headroom and
skb->protocol says nothing about it.
When netlink_dump() had this problem it was fixed by
skb_reset_network_header() after skb_reserve(). See
commit 99c07327ae11 ("netlink: reset network and mac headers in netlink_dump()").
pw-bot: cr
prev parent reply other threads:[~2026-09-19 23:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 20:35 Hui Peng
2026-09-19 23:18 ` Alexei Starovoitov [this message]
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=DLJODTPSL3IT.1LQ0SJ80PGO1M@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=benquike@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@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
all inboxes | Powered by JetHome®