From: 陈乐 <tom2cat@sjtu.edu.cn>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG][BPF] Kernel Bug Triggered when Ebpf Verifier Check Fails
Date: Fri, 27 Jun 2025 11:52:27 +0800 (CST) [thread overview]
Message-ID: <1444123482.1827743.1750996347470.JavaMail.zimbra@sjtu.edu.cn> (raw)
Hi BPF maintainers,
I'm reporting a bug I encountered in the BPF subsystem on Linux kernel version <<5.19.5>>, <<6.15.0-rc2-00577-g8066e388be48-dirty>>, <<6.15.3>>.
I wrote a BPF program that triggered a verifier rejection, but at the same time, the kernel emitted a BUG() warning at <<kernel/bpf/hashtab.c:222>>, suggesting a potential kernel-side issue rather than just verifier rejection. Later on, I discovered that constructing any ebpf Verifier rejection behavior within the specified code snippets would trigger this kernel bug.
- Miniest poc code:
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
struct mac_table_entry
{
struct bpf_timer expiration_timer;
__u32 ifindex;
__u64 last_seen_timestamp_ns;
struct in_addr border_ip;
};
struct
{
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, struct mac_address);
__type(value, struct mac_table_entry);
__uint(max_entries, 4 * 1024 * 1024);
__uint(pinning, LIBBPF_PIN_BY_NAME);
} mac_table SEC(".maps");
SEC("xdp.frags")
long mac_xdp_func(struct xdp_md *ctx)
{
// Constructing any code segment that does not meet the requirements of BPF Validator
// can trigger a kernel BUG: sleeping function called from invalid context at kernel/bpf/hashtab.c:222:
while(1){
__u32 j;
}
return XDP_PASS;
}
char LICENSE[] SEC("license") = "Dual BSD/GPL";
- Kernel version: <<6.15.3...>>
- Architecture: <<x86_64>>
- dmesg excerpt: <<BUG: sleeping function called from invalid context at kernel/bpf/hashtab.c:222>>
Detailed info including reproducible BPF program and kernel logs have been filed on Bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220278
Please let me know if you need more information or if I can help test a patch.
Thanks,
Le Chen;
tom2cat@sjtu.edu.cn;
next reply other threads:[~2025-06-27 3:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 3:52 陈乐 [this message]
2025-06-27 18:30 ` Alexei Starovoitov
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=1444123482.1827743.1750996347470.JavaMail.zimbra@sjtu.edu.cn \
--to=tom2cat@sjtu.edu.cn \
--cc=bpf@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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
all inboxes | Powered by JetHome®