Public bug reported:

[ Impact ]

  - On Noble systems testing 6.17 backport kernels (OEM/HWE/clouds, etc.) built
    with dwarves/pahole 1.25, the BPF selftests (TARGETS=bpf, e.g. ubuntu_bpf)
    fail to build. This was hinted for a while.

  - bpf_iter_tasks.bpf.o hits an implicit declaration of
    `bpf_copy_from_user_task_str`. The generated vmlinux.h is missing kfunc
    prototypes.

  - bpftool generates vmlinux.h from the kernel’s BTF. With dwarves 1.25 the BTF
    lacks `DECL_TAG bpf_kfunc`, so the kfunc section is empty and selftests see
    no prototypes. 

  - Newer `dwarves` (1.26+) would add these tags, but Noble stays on 1.25. This
    was discussed (at least for older series) years ago: Bug #1926330.

  - Backporting a newer `dwarves` is avoided, so an explicit tagging workaround
    in the kernel source is needed for 6.17 backport kernels.

  [ Test Plan ]

  1. On an unpatched 6.17 kernel built with dwarves 1.25, run:

     $ make -C linux/tools/testing/selftests TARGETS=bpf SKIP_TARGETS= clean 
all \
       KDIR=/usr/src/linux-headers-$(uname -r) \
       VMLINUX_BTF=/sys/kernel/btf/vmlinux

     Expect an implicit-decl error at progs/bpf_iter_tasks.c:98.
  2. Apply the patch rebuild the 6.17 kernel package, install, and reboot.
  3. Verify on the running kernel:

     $ bpftool btf dump file /sys/kernel/btf/vmlinux format c | grep \
       bpf_copy_from_user_task_str

     should show an extern prototype.
  4. Re-run the selftest build as in step 1; it should succeed.
  5. Optionally run the autotest suite for ubuntu_bpf to confirm tests run.
  6. Verified in a Noble VM: clang 18 + dwarves 1.25

  [ Where problems could occur ]

  - The change adds decl tags to all kfuncs in BTF. If wrong, vmlinux.h could
    gain unexpected kfunc prototypes, and other selftests might start failing at
    build time if their kfuncs are missing. If BTF generation broke, bpftool or
    selftest builds would fail. 
  - Runtime behavior and ABI are unchanged.

  [ Other Info ]

  - Upstream addresses this by passing `decl_tag_kfuncs` to a newer `dwarves`
    (commit ebb79e96f1ea, "kbuild: bpf: Tell pahole to DECL_TAG kfuncs", June
    12, 2024) and by having bpftool emit kfunc prototypes (commit 770abbb5a25a,
    "bpftool: Support dumping kfunc prototypes from BTF"). 

  - Questing (24.10) ships dwarves 1.27, so this resolves there
automatically.

** Affects: linux (Ubuntu)
     Importance: Medium
     Assignee: Cengiz Can (cengizcan)
         Status: New

** Affects: linux (Ubuntu Noble)
     Importance: Medium
     Assignee: Cengiz Can (cengizcan)
         Status: In Progress


** Tags: test

** Also affects: linux (Ubuntu Noble)
   Importance: Undecided
       Status: New

** Changed in: linux (Ubuntu)
     Assignee: (unassigned) => Cengiz Can (cengizcan)

** Changed in: linux (Ubuntu Noble)
     Assignee: (unassigned) => Cengiz Can (cengizcan)

** Changed in: linux (Ubuntu Noble)
   Importance: Undecided => Medium

** Changed in: linux (Ubuntu Noble)
       Status: New => In Progress

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2136848

Title:
  selftests/bpf: kfunc prototypes missing in vmlinux.h on Noble 6.17
  kernels built with dwarves 1.25

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2136848/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to