THE LINUX FOUNDATION PROJECTS

By Zhengjie Ji, Virginia Tech

eBPF lets developers run their own programs at specific points in the Linux kernel. For example, a program can record information about a system call or decide whether to allow an incoming packet through. Because these programs run in the kernel, Linux checks their compiled BPF instructions at load time using the eBPF verifier. If the verifier cannot establish that a program meets its safety requirements, the kernel rejects the load. Developers can request a record of the verification process, called the verifier log. In this post, we present an empirical study of how well existing verifier logs help developers understand why an eBPF program was rejected and decide how to fix it [1].

1. eBPF Verifier and Its Outputs

When loading an eBPF program, the Linux kernel uses the verifier to check whether the program can run safely. The verifier analyzes the compiled BPF instructions, tracking values in registers and on the stack along the paths the program may take. At each instruction, it uses what it knows from earlier operations and branch conditions to determine whether the instruction can safely use its operands. The kernel loads the program only after it passes verification [2].

When the verifier rejects a program, the verifier log can include the following information.

  • BPF instructions. The instruction number and disassembly for each instruction shown.
  • Register state. What the verifier knows about each reported register on the current path, including its type and any known value or range.
  • Line info. The source filename, line number, and source text associated with a BPF instruction.
  • Verifier error message. The specific error the verifier reports when it rejects the program.

2. Case Study: Debugging a Kernel Function Call Counter

We use a case from Aya, a Rust library for eBPF development, to illustrate the difficulties developers face when using a verifier log to fix a rejected program. We compare the test program and log from the issue report [3] with the fix that Aya merged. This lets us see what a developer could learn from the log and where they needed more information.

2.1 The Counter Program and Its Verification Error

Consider first what the test program is meant to do. The program in Figure 1(a) uses a kprobe to update two counters whenever a kernel function is called. The counters are static variables, MASK and MASK2, initialized to 1 and 0, respectively. Each time the program runs, it increments both counters.

(a) Counter program

static mut MASK: usize = 1;
static mut MASK2: usize = 0;
#[kprobe]
pub fn myapp(ctx: ProbeContext) -> u32 {
    unsafe {
        MASK += 1;
        MASK2 += 1;
    }
    0
}

(b) Verifier log (excerpt)

4: (7b) *(u64 *)(r1 +0) = r2    ; R1_w=map_value(...) ...
5: (18) r1 = ...                ; R1_w=map_ptr(...)
...
9: (7b) *(u64 *)(r1 +0) = r2
only read from bpf_array is supported

Figure 1. The Aya counter program and the verifier log for its two writes.

The problem arose when the developer tried to load the program. The verifier rejected it before it could run. For the second update, the verifier reported “only read from bpf_array is supported” (Figure 1(b)). The source increments a variable, yet the error message describes a restriction on access to an array map. What does that restriction have to do with the counter?

2.2 Diagnosing and Fixing the Rejected Write

To understand the error message, we first need to identify the operation it refers to in the source. Incrementing a counter takes three steps. The program reads its old value, adds one, and writes the new value back. The error message follows BPF instruction 9, which stores the new value from R2 at the address in R1. The verifier therefore rejected the last step of MASK2 += 1, writing the result back to the counter.

The next question is why only one of the two updates passed the check. In Figure 1(b), instructions 4 and 9 are identical. Both write through R1. The difference is what R1 points to. For the first update, the verifier records R1 as map_value, a pointer to the map value that holds the count. Before the second update, it records R1 as map_ptr, a pointer to the map object itself. The read-only restriction in the error message applies to direct access to that object.

To decide where to make the fix, we also need to know how the two writes got their addresses. The answer lies in how Aya’s loader handles static variables. Aya stores these variables in BPF maps. For MASK, initialized to 1, the old loader read the initial data from the object file and made the instruction reference the map value. The zero-initialized MASK2 resides in the .bss section. The file records how much space the section needs but contains no initialization bytes for it. When the initial data was empty, the loader made the instruction reference the map object itself. That is how the second write ended up with the wrong address [4].

The fix in Aya addressed how the loader initialized .bss. The loader now prepares zero-filled initial data of the size declared for the section. With that data present, it resolves the reference to MASK2 to the address of the map value, so the second update writes the count back to the correct location [5].

2.3 What Makes Verifier Logs Difficult to Use for Repair?

Comparing the log with the actual fix reveals two difficulties the developer faced in this case.

  1. The first difficulty is understanding the log. The verifier describes the problem in terms of BPF instructions and register states, which makes the log hard to interpret when working from the source. To understand why a counter increment was reported as a write to a map object, the developer had to read the store instruction and understand what the type of R1 meant for that write.
  2. The second difficulty is finding the code that needs to change. A source line can show where a problem appears. The developer still has to determine which change will resolve it. Mapping instruction 9 to MASK2 += 1 identifies where the program used the wrong address. The fix belonged in the loader code that produced the address.

To find out how well these observations generalize, we examined verifier logs and repair evidence across 235 rejection cases. The study asks what the logs tell developers and what changes address different reasons for rejection.

3. Empirical Study: How Well Do eBPF Verifier Logs Guide Repairs?

We conducted an empirical study of how well verifier logs help explain rejections and guide repairs. We compared the logs from 235 reproduced cases with the available evidence about their causes and repairs, including developer reports and kernel selftests [1, 6]. We asked two questions.

  1. Question 1. How clearly and accurately does the verifier log explain why a program was rejected?
  2. Question 2. What did developers change to address each cause of rejection?

3.1 Classifying 235 eBPF Verifier Rejections by Cause

We began by collecting cases for which we could examine a verifier rejection and the problem behind it. We gathered 936 candidates from Stack Overflow, GitHub issues and fix commits, and Linux kernel selftests. We rebuilt candidate programs with Clang 18 and attempted to load them on Linux 6.15.11 with verifier log level 2. We retained 235 reproducible rejections. For external reports, the dataset includes reconstructed programs where necessary. We interpreted the resulting logs using the source and repair evidence available for each case [1, 6].

We then classified the 235 rejections by cause. For each case, we compared the rejected program with the developer’s fix to identify the problem the change addressed. Table 1 shows the four causes we found and the number of cases in each category.

Table 1. Categories of the 235 reproduced verifier rejections.

Rejection category Cases
Source-level bug 191
Compiler-dependent rejection 18
Environment or configuration 14
Verifier-related rejection 12
Total 235

The dataset labels seven of the 12 verifier-related cases as false positives and five as verifier limits.

We examined source-level bugs in more detail because they accounted for 191 of the 235 rejections (81%). Using the developer’s fix, we identified the requirement each program failed to meet. Table 2 shows the resulting 12 categories.

Table 2. Causes of the 191 source-level bugs

Cause Cases
Scalar offset or length without a range bound 24
Corrupted or stale dynamic pointer (bpf_dynptr) 23
At least one path reaches a packet access without a bounds check 22
Missing null check 19
Pointer type or provenance mismatch 16
Unverified address dereferenced 16
Index exceeds object capacity 15
Context or interface contract misuse 15
Unpaired resource reference 15
Interrupt flags restored out of order 11
Probe signature mismatched with the target application binary interface (ABI) 9
Oversized or uninitialized stack buffer 6
Total 191

3.2 Question 1 — How Well Do Verifier Logs Explain Why a Program Was Rejected?

Question 1 asks how clearly verifier logs explain why a program was rejected. For verifier error messages, we examined whether the same wording could describe rejections with different causes. For the states recorded by the verifier, we examined whether a developer could tell how the problem arose.

We first looked at how well error messages distinguish among causes. We compared the error message in each case with the cause we had identified from the fix. Across the 235 cases, we found 167 distinct error messages. Replacing register numbers, offsets, and other numeric values with placeholders left 82 message templates. Of these, 15 covered more than one cause. Table 3 shows the four most common templates. The first reports that a program used a scalar as a pointer to access memory. Across the 28 cases with that message, we found nine different causes.

Table 3. Error message templates associated with multiple causes. R# denotes a register number.

Error message template Cases Distinct causes
R# invalid mem access ‘scalar’ 28 9
invalid access to packet 26 5
invalid access to map value 18 4
R# !read_ok 13 4

We next examined what the recorded states tell a developer about the cause of a rejection. Consider a program that reads the UDP destination port from a packet. It calculates the UDP header address based on the IP version, checks that the header fits within the packet, and then reads the port. At the read, the verifier reported that register R5 held a scalar. The source had already checked the header bounds. What could the developer learn from the log about why the verifier no longer recognized R5 as a packet pointer?

from 31 to 34: ... R5_w=40 ...
; if (udph + sizeof(struct udphdr) > data_end) @ prog.c:267
35: (07) r3 += 8                 ; R3=48
36: (2d) if r3 > r2 goto pc+4    ; R2=pkt_end() R3=48
; dst_port = ...((struct udphdr *)udph)->dest; @ prog.c:270
37: (69) r2 = *(u16 *)(r5 +2)
R5 invalid mem access 'scalar'

Figure 2. Verifier log for the rejected UDP destination-port read.

To interpret the recorded states, we can start at the rejected read in Figure 2 and trace the address back through the log. Instruction 37 reads the port from R5 + 2. Earlier in the full log, the verifier recognized R5 as a packet pointer. By instruction 34, however, it recorded R5_w=40, meaning that it treated R5 as the integer 40. This tells the developer that the verifier had already lost track of the pointer before the read. To understand why it lost track, the developer still has to relate the instructions on that path to the branches that calculate the UDP header address in the source.

Based on these findings, we can now answer Question 1 about how clearly and accurately the verifier log explains why a program was rejected. We found that a log could explain why the verifier rejected a particular instruction while leaving the cause of the failure unclear. The same error message appeared in programs with different underlying problems. The recorded states provided clues that could distinguish those problems, but interpreting those clues required developers to trace register values through the BPF instructions and relate the operations on those values to the source code.

3.3 Question 2 — What Changes Are Needed to Resolve an eBPF Verifier Rejection?

Question 2 asks how developers fixed programs rejected for different reasons. We compared the fixes across the four categories introduced in Table 1. Developers changed the program’s source code, its compiler settings, or the environment in which it ran. Table 4 shows which changes they made for each cause of rejection.

Table 4. Repair approaches by rejection category.

Rejection category Repair approach
Source-level bug Correct the source operation or add the missing safety check.
Compiler-dependent rejection Change a compiler option or rewrite the source so the generated instructions retain the information the verifier needs.
Environment or configuration Use a compatible kernel, program type, or configuration.
Verifier-related rejection Restructure the program to stay within a verifier limit, or work around a false positive with an equivalent rewrite.

Two programs in our study illustrate why the verifier error message alone may give developers little guidance about what to change. Both programs read a packet header field. As Figure 3 shows, the verifier reported the same error in both cases apart from the register number: each program used a scalar as a pointer.

(a) IPv4 protocol read

17  if (eth->h_proto == bpf_htons(ETH_P_IP)) {
18      struct iphdr *iph2 = (void *)(sizeof(*eth) + nh_off);
        // integer offset, no packet base
19      return iph2->protocol;  // rejected here
20  }

R1 invalid mem access 'scalar'

(b) UDP destination-port read

263  if (ipv4_hdr)
264      udph = (void *)ipv4_hdr + sizeof(*ipv4_hdr);
265  else
266      udph = (void *)ipv6_hdr + sizeof(*ipv6_hdr);
267  if (udph + sizeof(struct udphdr) > data_end)
     // udph (merged) bounds-checked
268      return 1;
269
270  dst_port = __constant_ntohs(((struct udphdr *)udph)->dest);
     // rejected here

R5 invalid mem access 'scalar'

Figure 3. The reproduced IPv4 and UDP reads matched the same verifier error message template.

The two reads differed in how their source code produced the packet address. For the IPv4 read, the expression added two offsets without a packet base. The accepted answer recommends deriving the header pointer from the packet base [7]. For the UDP read, the source already checked the header bounds. The developer reported two changes that worked: explicitly testing the IPv6 header pointer on the alternative branch, or selecting the header by EtherType [8]. One repair supplies a missing base address. The other changes how the program selects an address it has already checked.

Based on the fixes we examined, we can now answer Question 2 about what developers changed to address each cause of rejection. Depending on the cause, developers modified the eBPF source code, adjusted compiler settings, or chose a kernel or BPF program type that supported the feature they needed. Programs with the same verifier error message sometimes required different fixes, so the message alone did not reliably tell developers what to change.

4. Designing eBPF Verifier Diagnostics to Guide Repair

Our study showed that the error message at the rejected instruction often gives developers too little information to decide how to fix a program. We therefore looked at what else the verifier knows when it checks a program and how that information can help explain a rejection and guide a fix.

4.1 Reusing the Verifier’s Analysis to Explain a Rejection

Explaining a rejection starts with the safety condition the operation requires and why the verifier could not establish it. Developers also need to know which part of the source accounts for the failure. The reported line can show where the problem surfaced, but deciding what to change may require looking at earlier code.

Our approach reuses the analysis the verifier has already performed. As the verifier follows paths through the BPF instructions, the log records what it knows at different points, including the types of values in registers and their possible ranges. Comparing the requirements of the rejected instruction with the state at that point tells us which safety condition the verifier could not establish. Tracing the relevant value back along the same path can then show whether the verifier ever established that condition and, if so, where the verifier could no longer establish it. The source line information in the log maps those instructions back to the source code.

4.2 How BPFix Generates Source-Level Diagnostics

We used this approach to build BPFix, a user-space command-line tool that helps developers understand and fix rejected eBPF programs. When the kernel rejects a program at load time, BPFix reads the verifier log and produces a source-level diagnostic. It identifies the rejected operation, explains why the verifier rejected it, and indicates where to look for a fix.

Figure 4 shows how BPFix turns a verifier log into a source-level diagnostic. Its three components reconstruct the recorded states, locate the safety condition the verifier could not establish, and generate a diagnostic.

Figure 4. BPFix workflow.

  1. State Reconstruction recovers the verifier state at individual instructions. The log gives the full state only at certain points. Starting from each of these records, BPFix applies the changes recorded at subsequent instructions along the same path to reconstruct what the verifier knew about registers and stack slots.
  2. Proof Localization identifies the missing safety condition and locates the relevant source lines. BPFix uses the error message, the rejected instruction, and the state at that instruction to determine which value needed to satisfy which condition. It then traces the value back to its origin, follows the changes in its state, and maps the relevant instructions to source lines.
  3. Diagnostic Generation explains the rejection and suggests a fix. BPFix matches the error message, instruction, and states against known problem patterns. A specific match yields a corresponding repair suggestion. If BPFix can identify only the kind of safety condition involved, it suggests what to check for that class of problem.

To see how these steps work together, consider the program that reads a UDP destination port. Line 267 checks that the UDP header fits within the packet before line 270 reads the port. Yet the verifier reports R5 invalid mem access ‘scalar’ at the read. Why did it reject the read despite the earlier bounds check?

BPFix starts by tracing the address used by the rejected load. An earlier state shows that the verifier recognized the value in R5 as a packet pointer. By the time the path reaches instruction 34, the verifier records R5 as the scalar value 40. Instruction 37 then uses R5 as the base address for the load. BPFix marks the change in type alongside the bounds check at line 267. At line 270 it points out that the read uses a value the verifier now treats as a scalar.

Figure 5 shows how BPFix distinguishes the two packet reads that produced the same verifier error message. For the first program, it classifies the rejection as a source-level bug. For the UDP program, it identifies the compiler-generated instructions as a possible reason the verifier lost track of the packet pointer. The diagnostic marks the bounds check at line 267 and the rejected read at line 270 so the developer can see which source operations are involved.

(a) IPv4 protocol read

error[BPFIX-E011]: scalar or pkt_end value is used where the verifier
       requires a real pointer
  = class: source_bug
  = verifier[31]: R1 invalid mem access 'scalar'

(b) UDP destination-port read

error[BPFIX-E006]: verifier-visible compiler lowering hides the
       required proof
  = class: lowering_artifact
  = confidence: medium
  = next action: provenance
  --> prog.c:270
    |
263 | if (ipv4_hdr)
    | ------------- nearby source context for pointer provenance
267 | if (udph + sizeof(struct udphdr) > data_end)
    | -------------------------------------------- verifier state
           changes from pkt to scalar before the rejected access
270 | dst_port = __constant_ntohs(((struct udphdr *)udph)->dest);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           rejected here: verifier sees a scalar where a pointer
           is required
    |
    = verifier[229]: R5 invalid mem access 'scalar'
    = required proof: preserve a verifier-recognized pointer type at
           the operation that requires a pointer
help: Reacquire a verifier-tracked pointer before the rejected
      dereference.
help: Use the packet pointer that received the data_end proof, or
      rederive and recheck it before the load.

Figure 5. BPFix diagnostics for the two packet reads in Figure 3.

How does the UDP diagnostic compare with the reported fix? BPFix points to the pointer used for the read and suggests using a checked packet pointer or deriving and checking it again. The developer reported fixing the rejection by changing how the source selected the IPv4 or IPv6 header [8]. The diagnostic directs attention to the relevant pointer, although the developer’s change differs from the suggested edit.

5. Related Work: Redesigning eBPF Verifier Error Reporting in Upstream Linux

Linux kernel developers are improving how the eBPF verifier reports errors. Kumar Kartikeya Dwivedi’s Redesign Verification Errors patch series aims to help developers understand which verifier rule a program failed to satisfy, which operations on the path led to that failure, and how they might change the program [9].

The series introduces a common framework for diagnostics. The plan is to extend it to more errors and make its repair suggestions more specific. The follow-up work outlined in the series falls into three areas [9].

  • Cover more errors and warnings. Bring more checks that currently emit only a short error message into the framework, and use it to report verifier warnings. Diagnostics for programs rejected because they reach a verifier limit were also deferred to follow-up work.
  • Explain why verification failed. Incorporate summaries of why loop analysis failed to converge, and explore how to associate source variables with verifier registers when debug information permits.
  • Refine repair suggestions. Tailor suggestions to each error category, identify kfuncs or helpers that can release a resource the program owns, and link to relevant documentation where useful.

The first 14 patches have been merged into the mainline kernel. For the errors they cover, the verifier appends a diagnostic to the existing log. It identifies the rejected BPF instruction and its source location when available, shows the branches and state changes that led to the failure, and suggests a possible fix. The initial reports cover selected errors in seven categories: register type safety, memory safety, resource lifetime safety, call type safety, execution context safety, program structure, and policy [9]. Subsequent patches have corrected source locations and explanations for some errors so that the diagnostic reflects the check that actually failed [10–12].

The upstream work and our research share the goal of helping developers understand why the verifier rejected their program. The upstream verifier records and reports the operations that led a check to fail. Our research starts with the evidence about what had to change across 235 rejection cases. We found that even when a log explains why an instruction failed, identifying the code or configuration that needs to change can require additional evidence. We built BPFix on this observation. It analyzes existing verifier logs in user space, maps the state changes that contributed to a rejection back to the source, and identifies where a change may be needed.

6. Next Steps: A BPFix Tutorial and Repair Evaluation Results

The next post will show how to use BPFix to diagnose a rejection and test a proposed fix. BPFix and its quick start are already available [13]. We plan to publish a tutorial that takes a rejected program through the full repair process: collecting the verifier log, interpreting the diagnostic, revising the program, and testing the change. We will also present our findings on how well BPFix diagnostics guide repairs to rejected eBPF programs.

Acknowledgments

The research described in this post is joint work with Yusheng Zheng, Zhengjie Ji, Weichen Tao, Xiangyu Gao, Jianchang Su, Wei Zhang, Andi Quinn, and Dan Williams. The eBPF Research Fund supports this project.

References

[1] Yusheng Zheng, Zhengjie Ji, Weichen Tao, Xiangyu Gao, Jianchang Su, Wei Zhang, Andi Quinn, and Dan Williams. Characterizing and Bridging the Diagnostic Gap in eBPF Verifier Rejections. Proceedings of the 4th Workshop on eBPF and Kernel Extensions (eBPF ’26), ACM, 2026. DOI: 10.1145/3837779.3838156.

[2] Linux kernel project. eBPF verifier, BPF Type Format (BTF), and verifier implementation. Linux v6.15.11.

[3] Godones. Error: the BPF_PROG_LOAD syscall failed. Aya issue #1002, July 28, 2024.

[4] Aya project. Map relocation logic in aya-obj/src/relocation.rs. Revision f9b34fe, lines 261–267.

[5] Dave Tucker. fix(aya): BSS Sections must be filled with zeros. Aya pull request #1073, November 1, 2024.

[6] BPFix project. bpfix-empirical: Reproduced verifier rejections. Commit ac8f2f5a5836.

[7] Stack Overflow. I have an error trying to access iphdr using eBPF, accepted answer.

[8] Stack Overflow. Question 53136145, developer’s accepted answer on selecting the UDP header.

[9] Linux kernel project. Merge branch ‘redesign-verification-errors’. Commit ce7c9f6c599b, August 15, 2026.

[10] Kumar Kartikeya Dwivedi. bpf: Report non-sleepable kfunc programs accurately. Commit dac3b7a30d7e, September 24, 2026.

[11] Kumar Kartikeya Dwivedi. bpf: Correct verifier diagnostic attribution for stack reads. Commit 9774ae5951c2, September 24, 2026.

[12] Kumar Kartikeya Dwivedi. bpf: Correct Program Structure diagnostic context. Commit d91052063bee, September 30, 2026.

[13] BPFix project. BPFix: Quick Start.