All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: 梅开彦 <kaiyanm@hust.edu.cn>, daniel@iogearbox.net
Cc: bpf@vger.kernel.org, dddddd@hust.edu.cn, dzm91@hust.edu.cn,
	hust-os-kernel-patches@googlegroups.com, ast@kernel.org,
	andrii@kernel.org
Subject: Re: bpf: missing transport_header validation in bpf_prog_test_run_skb triggers WARNING
Date: Mon, 3 Nov 2025 10:50:12 -0800	[thread overview]
Message-ID: <67580a99-8bfd-45f9-8ff8-90b333ca4b40@linux.dev> (raw)
In-Reply-To: <521587d9.3a2f4.19a4918cc8b.Coremail.kaiyanm@hust.edu.cn>

On 11/3/25 1:42 AM, 梅开彦 wrote:
> Our fuzzer tool discovered a missing check for `transport_header` field initialization
> in the `bpf_prog_test_run_skb` function within the Linux kernel's BPF subsystem. This
> vulnerability will lead to a WARNING issue.
> 
> Reported-by: Kaiyan Mei <M202472210@hust.edu.cn>
> Reported-by: Yinhao Hu <dddddd@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> 
> ## Root Cause
> 
> In the `bpf_prog_test_run_skb` funtion, the `skb` created for BPF program execution
> may have uninitialized `transport_header` (remaining as the magic value ~0U).
> When the BPF program calls `bpf_skb_check_mtu` helper, it eventually reaches
> `skb_gso_validate_network_len()` which assumes `skb->transport_header` is properly
> set. The access to uninitialized transport header through `skb_transport_header()`
> triggers the WARNING.
> 
> ## Reproduction Steps
> 
> 1. **BPF Program**: Load a simple BPF program that calls `bpf_check_mtu`
>     
> 2. **Context**: Create `__sk_buff` with following fields:
>      - `skb->gso_size = 0x1`
>      - `skb->ifindex = 0x0e`
>      This would ensure the `skb_gso_validate_network_len()` funtion could be reached
> within the `bpf_skb_check_mtu` helper.
> 
> 3. **Trigger**: Execute the program via `BPF_PROG_TEST_RUN`
>     The kernel detects the uninitialized `transport_header` field in `skb_transport_header` and
> triggers WARNING.
>      
> 
> ## KASAN Report
> 
> ```
> WARNING: CPU: 0 PID: 9932 at ./include/linux/skbuff.h:3071 skb_transport_header include/linux/skbuff.h:3071 [inline]

I think it needs a skb_reset_transport_header in bpf_prog_test_run_skb().


      reply	other threads:[~2025-11-03 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03  9:42 bpf: missing transport_header validation in bpf_prog_test_run_skb triggers WARNING 梅开彦
2025-11-03 18:50 ` Martin KaFai Lau [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=67580a99-8bfd-45f9-8ff8-90b333ca4b40@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dddddd@hust.edu.cn \
    --cc=dzm91@hust.edu.cn \
    --cc=hust-os-kernel-patches@googlegroups.com \
    --cc=kaiyanm@hust.edu.cn \
    /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.