Re: [RFC PATCH v1 01/11] unwind: Add Minimal DWARF CFI bytecode interpreter and KUnit tests

From: bot+bpf-ci

Date: Sun Nov 22 2026 - 19:40:21 EST


> unwind: Add Minimal DWARF CFI bytecode interpreter and KUnit tests

TL;DR:
- Disabling KMSAN for dwarf_cfi.o may cause false uninit-value reports on
returned rows
- Commit message and header misdescribe indirect-encoding rejection
- Kernel-doc claims test use of module indexing helpers that tests never call

> diff --git a/kernel/unwind/Makefile b/kernel/unwind/Makefile
> --- a/kernel/unwind/Makefile
> +++ b/kernel/unwind/Makefile
> @@ -1 +1,12 @@
> +ifdef CONFIG_FUNCTION_TRACER
> +CFLAGS_REMOVE_dwarf_cfi.o = $(CC_FLAGS_FTRACE)
> +endif
> +KASAN_SANITIZE_dwarf_cfi.o := n
> +KCSAN_SANITIZE_dwarf_cfi.o := n
> +UBSAN_SANITIZE_dwarf_cfi.o := n
> +KMSAN_SANITIZE_dwarf_cfi.o := n
> +KCOV_INSTRUMENT_dwarf_cfi.o := n

Can KMSAN_SANITIZE_dwarf_cfi.o := n cause false uninit-value reports?

Every public entry point in dwarf_cfi.c returns its result by storing into
a struct dwarf_cfi_row supplied by the caller:

dwarf_cfi_eval_fde_streams():
*out_row = row;

Without KMSAN instrumentation these stores do not update the shadow, while
the callers are instrumented and keep the row on their stack, where KMSAN
has poisoned it on function entry. The caller would then see row as
uninitialized as soon as it branches on a field, for example in the later
user unwinder:

unwind_user_next_cfi():
struct dwarf_cfi_row row;
...
err = dwarf_cfi_unwind_user_eh_frame_hdr(hdr_uaddr, hdr_size,
lookup_ip, &arch, &row);
...
if (row.ra_rule == DWARF_CFI_RULE_UNDEFINED) {

The same applies to the KUnit tests in this patch, which read row.cfa_base
and other fields after dwarf_cfi_eval_fde_kmem(), and to the x86 kernel
unwinder added later in the series.

Documentation/dev-tools/kmsan.rst warns that disabling instrumentation
produces wrong shadow and false positives, and other code that returns
data from uninstrumented code calls kmsan_unpoison_memory() on the output.
dwarf_cfi.c only reads .eh_frame data and memory obtained through
copy_from_user(), which unpoisons its destination, so would
KMSAN_ENABLE_CHECKS_dwarf_cfi.o := n (or no KMSAN switch at all) be enough
here while keeping shadow propagation for out_row?

[ ... ]

> diff --git a/kernel/unwind/dwarf_cfi.c b/kernel/unwind/dwarf_cfi.c
> --- /dev/null
> +++ b/kernel/unwind/dwarf_cfi.c

[ ... ]

> + case 'P':
> + /* Personality encoding + pointer; skipped without deref */
> + err = cfi_read_u8(s, &enc);
> + if (err)
> + return err;
> + psize = cfi_encoded_ptr_size(enc & ~DW_EH_PE_indirect,
> + arch->ws);

This isn't a bug, but the commit message says:

> DW_EH_PE_indirect pointer encodings are unconditionally rejected with
> -EINVAL.

and the file header comment says "expressions and indirect pointer
encodings are rejected".

dwarf_cfi_parse_cie() masks DW_EH_PE_indirect off the 'P' personality
encoding and accepts it, and the 'L' LSDA encoding byte is accepted
whatever its value. Only the 'R' FDE encoding and cfi_read_encoded_ptr()
reject DW_EH_PE_indirect.

Skipping the personality pointer without dereferencing it looks correct,
and the function's own kernel-doc describes that accurately. Could the
commit message and the file header say that indirect encodings are
rejected for pointers that are decoded (FDE initial_location/range and
.eh_frame_hdr fields), and that personality/LSDA pointers are skipped
without being dereferenced?

[ ... ]

> + * @out_count: Output number of valid FDEs discovered in [@eh_start, +@eh_size).
> + *
> + * Used at module load time (and in tests) to construct a binary-search FDE
> + * lookup table when the linker has not emitted a separate .eh_frame_hdr.

This isn't a bug, but the kernel-doc says dwarf_cfi_scan_eh_frame_kmem() is
used "in tests". kernel/unwind/dwarf_cfi_kunit.c never references
dwarf_cfi_scan_eh_frame_kmem(), dwarf_cfi_mod_alloc(),
dwarf_cfi_mod_eval() or dwarf_cfi_unwind_user_eh_frame_hdr(), and the only
caller of dwarf_cfi_scan_eh_frame_kmem() is dwarf_cfi_mod_alloc().

Should the comment drop "(and in tests)", or should a test be added that
indexes a small .eh_frame blob through dwarf_cfi_mod_alloc() and
dwarf_cfi_mod_eval()?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/45087188604