ubuntu_bpf failed to build with j-oem-6.1.0-1018.18

Bug #2028932 reported by Po-Hsu Lin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-kernel-tests
New
Undecided
Unassigned
linux (Ubuntu)
Triaged
Undecided
Unassigned
Jammy
Invalid
Undecided
Unassigned
linux-oem-6.1 (Ubuntu)
Invalid
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned
linux-oem-6.5 (Ubuntu)
Invalid
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned

Bug Description

Issue found with J-oem-6.1.0-1018.18

Test build failed with:
    CLNG-BPF [test_maps] test_check_mtu.bpf.o
    CLNG-BPF [test_maps] test_cls_redirect.bpf.o
  make[1]: Leaving directory '/home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf'
  make: Leaving directory '/home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests'
  stderr:
  progs/test_cls_redirect.c:90:2: error: static_assert expression is not an integral constant expression
          sizeof(flow_ports_t) !=
          ^~~~~~~~~~~~~~~~~~~~~~~
  progs/test_cls_redirect.c:91:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                  offsetofend(struct bpf_sock_tuple, ipv4.dport) -
                  ^
  progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
          (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
           ^
  /home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
  #define offsetof(type, member) ((unsigned long)&((type *)0)->member)
                                   ^
  progs/test_cls_redirect.c:95:2: error: static_assert expression is not an integral constant expression
          sizeof(flow_ports_t) !=
          ^~~~~~~~~~~~~~~~~~~~~~~
  progs/test_cls_redirect.c:96:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                  offsetofend(struct bpf_sock_tuple, ipv6.dport) -
                  ^
  progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
          (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
           ^
  /home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
  #define offsetof(type, member) ((unsigned long)&((type *)0)->member)
                                   ^
  2 errors generated.
  make[1]: *** [Makefile:531: /home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf/test_cls_redirect.bpf.o] Error 1
  make: *** [Makefile:160: all] Error 2

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Test build ok with -1017 source code.

Timo Aaltonen (tjaalton)
Changed in linux-oem-6.1 (Ubuntu):
status: New → Invalid
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

I just finished bisect between -1007 and -1008

ca6f352ba5c8ccde01289d433401f28e6c260e07 is the first bad commit
commit ca6f352ba5c8ccde01289d433401f28e6c260e07
Author: Andrii Nakryiko <email address hidden>
Date: Mon May 8 23:55:02 2023 -0700

    libbpf: fix offsetof() and container_of() to work with CO-RE

    BugLink: https://bugs.launchpad.net/bugs/2028528

    [ Upstream commit bdeeed3498c7871c17465bb4f11d1bc67f9098af ]

    It seems like __builtin_offset() doesn't preserve CO-RE field
    relocations properly. So if offsetof() macro is defined through
    __builtin_offset(), CO-RE-enabled BPF code using container_of() will be
    subtly and silently broken.

    To avoid this problem, redefine offsetof() and container_of() in the
    form that works with CO-RE relocations more reliably.

    Fixes: 5fbc220862fc ("tools/libpf: Add offsetof/container_of macro in bpf_helpers.h")
    Reported-by: Lennart Poettering <email address hidden>
    Signed-off-by: Andrii Nakryiko <email address hidden>
    Acked-by: Yonghong Song <email address hidden>
    Link: https://<email address hidden>
    Signed-off-by: Alexei Starovoitov <email address hidden>
    Signed-off-by: Sasha Levin <email address hidden>
    Signed-off-by: Timo Aaltonen <email address hidden>

 tools/lib/bpf/bpf_helpers.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Timo Aaltonen (tjaalton)
Changed in linux (Ubuntu Jammy):
status: New → Invalid
Changed in linux (Ubuntu):
status: New → Triaged
Revision history for this message
Po-Hsu Lin (cypressyew) wrote (last edit ):

This is failing with Lunar + 6.5-rc3 (clang-15, llvm-15, gcc-12), as well:

  CLNG-BPF [test_maps] test_check_mtu.bpf.o
  CLNG-BPF [test_maps] test_cls_redirect.bpf.o
progs/test_cls_redirect.c:90:2: error: static assertion expression is not an integral constant expression
        sizeof(flow_ports_t) !=
        ^~~~~~~~~~~~~~~~~~~~~~~
progs/test_cls_redirect.c:91:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                offsetofend(struct bpf_sock_tuple, ipv4.dport) -
                ^
progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
        (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
         ^
/home/ubuntu/mainline-crack/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
#define offsetof(type, member) ((unsigned long)&((type *)0)->member)
                                 ^
progs/test_cls_redirect.c:95:2: error: static assertion expression is not an integral constant expression
        sizeof(flow_ports_t) !=
        ^~~~~~~~~~~~~~~~~~~~~~~
progs/test_cls_redirect.c:96:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                offsetofend(struct bpf_sock_tuple, ipv6.dport) -
                ^
progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
        (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
         ^
/home/ubuntu/mainline-crack/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
#define offsetof(type, member) ((unsigned long)&((type *)0)->member)
                                 ^
2 errors generated.
make[1]: *** [Makefile:576: /home/ubuntu/mainline-crack/tools/testing/selftests/bpf/test_cls_redirect.bpf.o] Error 1
make[1]: Leaving directory '/home/ubuntu/mainline-crack/tools/testing/selftests/bpf'
make: *** [Makefile:169: all] Error 2
make: Leaving directory '/home/ubuntu/mainline-crack/tools/testing/selftests'

ubuntu@autovm4:~/mainline-crack$ git log --oneline
a941e05c6 (grafted, HEAD, tag: cod/mainline/v6.5-rc3) debian changelog

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Tested again with Mantic 6.5.0-060500rc3-generic (clang-16, llvm-16, gcc-13), it can be build without any issue.

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

If you try to use clang-16, llvm-16 and gcc-13 on Lunar, it will complain about:
  MOD bpf_testmod.ko
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.1.0-8ubuntu1) 13.1.0
  You are using: Ubuntu clang version 15.0.7
  CC [M] /home/ubuntu/mainline-crack/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.o
clang: error: unknown argument: '-fconserve-stack'
clang: error: unsupported argument 'bounds-strict' to option '-fsanitize='
clang: error: unsupported option '-mrecord-mcount' for target 'x86_64-unknown-linux-gnu'
clang: error: '-ftrivial-auto-var-init=zero' hasn't been enabled; enable it at your own peril for benchmarking purpose only with '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang'
make[4]: *** [scripts/Makefile.build:243: /home/ubuntu/mainline-crack/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.o] Error 1
make[3]: *** [Makefile:2038: /home/ubuntu/mainline-crack/tools/testing/selftests/bpf/bpf_testmod] Error 2
make[2]: *** [Makefile:16: all] Error 2
make[1]: *** [Makefile:206: /home/ubuntu/mainline-crack/tools/testing/selftests/bpf/bpf_testmod.ko] Error 2
make[1]: Leaving directory '/home/ubuntu/mainline-crack/tools/testing/selftests/bpf'
make: *** [Makefile:169: all] Error 2

Revision history for this message
Timo Aaltonen (tjaalton) wrote :

please test -1019 from proposed, thanks

Changed in linux-oem-6.1 (Ubuntu Jammy):
status: New → Fix Committed
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

With 6.1.0-1019-oem in -proposed, the ubuntu_bpf test can be built without any issue. Thanks!

But to note that test_verifier test reported that there is a new failure:
  #906/p precise: ST insn causing spi > allocated_stack FAIL
  Unexpected verifier log!
  EXP: parent didn't have regs=10 stack=0 marks
  RES:
  func#0 @0
  0: R1=ctx(off=0,imm=0) R10=fp0
  0: (bf) r3 = r10 ; R3=fp0 R10=fp0
  1: (55) if r3 != 0x7b goto pc+0 ; R3=fp0
  2: (7a) *(u64 *)(r3 -8) = 0 ; R3=fp0 fp-8_w=00000000
  3: (79) r4 = *(u64 *)(r10 -8) ; R4_w=P0 R10=fp0
  4: (b7) r0 = -1 ; R0=-1
  5: (2d) if r4 > r0 goto pc+0
  last_idx 5 first_idx 5
  parent didn't have regs=1 stack=0 marks: R0_rw=P-1 R1=ctx(off=0,imm=0) R3=fp0 R4_rw=P0 R10=fp0 fp-8_w=00000000
  last_idx 4 first_idx 2
  regs=1 stack=0 before 4: (b7) r0 = -1
  6: (95) exit

  from 1 to 2: safe
  processed 8 insns (limit 1000000) max_states_per_insn 0 total_states 4 peak_states 4 mark_read 1

This probably came with some other patches from stable as well. This test case was good with 6.1.0-1015.15:
 #906/p precise: ST insn causing spi > allocated_stack OK

Revision history for this message
Timo Aaltonen (tjaalton) wrote :

right, but this bug is now verified ;)

tags: added: verification-done-jammy
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Yes that's correct, I will open a new bug for that.
Thanks!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package linux-oem-6.1 - 6.1.0-1019.19

---------------
linux-oem-6.1 (6.1.0-1019.19) jammy; urgency=medium

  * jammy/linux-oem-6.1: 6.1.0-1019.19 -proposed tracker (LP: #2029478)

  * ubuntu_bpf failed to build with j-oem-6.1.0-1018.18 (LP: #2028932)
    - SAUCE: Revert "libbpf: fix offsetof() and container_of() to work with CO-RE"

  * Regression: amdgpu mirror mode broken in -1018 (LP: #2028848)
    - Revert "drm/amd/display: edp do not add non-edid timings"

  * Miscellaneous Ubuntu changes
    - [Config] Update gcc/pahole versions.

 -- Timo Aaltonen <email address hidden> Sat, 05 Aug 2023 14:53:47 +0300

Changed in linux-oem-6.1 (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

This is also affecting J-oem-6.5:
  CLNG-BPF [test_maps] test_check_mtu.bpf.o
  CLNG-BPF [test_maps] test_cls_redirect.bpf.o
make[1]: Leaving directory '/home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf'
make: Leaving directory '/home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests'
stderr:
progs/test_cls_redirect.c:90:2: error: static_assert expression is not an integral constant expression
        sizeof(flow_ports_t) !=
        ^~~~~~~~~~~~~~~~~~~~~~~
progs/test_cls_redirect.c:91:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                offsetofend(struct bpf_sock_tuple, ipv4.dport) -
                ^
progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
        (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
         ^
/home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
#define offsetof(type, member) ((unsigned long)&((type *)0)->member)
                                 ^
progs/test_cls_redirect.c:95:2: error: static_assert expression is not an integral constant expression
        sizeof(flow_ports_t) !=
        ^~~~~~~~~~~~~~~~~~~~~~~
progs/test_cls_redirect.c:96:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                offsetofend(struct bpf_sock_tuple, ipv6.dport) -
                ^
progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
        (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
         ^
/home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
#define offsetof(type, member) ((unsigned long)&((type *)0)->member)
                                 ^
2 errors generated.
make[1]: *** [Makefile:577: /home/ubuntu/autotest/client/tmp/ubuntu_bpf/src/linux/tools/testing/selftests/bpf/test_cls_redirect.bpf.o] Error 1
make: *** [Makefile:169: all] Error 2

Changed in linux-oem-6.5 (Ubuntu):
status: New → Invalid
Timo Aaltonen (tjaalton)
Changed in linux-oem-6.5 (Ubuntu Jammy):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (8.6 KiB)

This bug was fixed in the package linux-oem-6.5 - 6.5.0-1003.3

---------------
linux-oem-6.5 (6.5.0-1003.3) jammy; urgency=medium

  * jammy/linux-oem-6.5: 6.5.0-1003.3 -proposed tracker (LP: #2033279)

  * Packaging resync (LP: #1786013)
    - [Packaging] update Ubuntu.md
    - [Packaging] update update.conf

  * Resync CI Runner Configuration (LP: #2024199)
    - [CI] resync ci configuration
    - [CI] resync ci configuration

  * i915: Backport some fixes for Meteor Lake, vol2 (LP: #2032781)
    - drm/i915/gsc: fixes and updates for GSC memory allocation
    - drm/i915/mtl/gsc: extract release and security versions from the gsc binary
    - drm/i915/mtl/gsc: query the GSC FW for its compatibility version
    - drm/i915/mtl/gsc: Add a gsc_info debugfs
    - drm/i915/gsc: Fix intel_gsc_uc_fw_proxy_init_done with directed wakerefs
    - drm/i915/display: Do not use stolen on MTL
    - drm/i915/huc: check HuC and GuC version compatibility on MTL
    - drm/i915/selftest/gsc: Ensure GSC Proxy init completes before selftests
    - drm/i915/color: Upscale degamma values for MTL
    - drm/i915/color: Downscale degamma lut values read from hardware
    - drm/i915/gt: Simplify shmem_create_from_object map_type selection
    - SAUCE: drm/i915: Make i915_coherent_map_type GT-centric
    - drm/i915/gt: Apply workaround 22016122933 correctly

  * ubuntu_bpf failed to build with j-oem-6.1.0-1018.18 (LP: #2028932)
    - SAUCE: Revert "libbpf: fix offsetof() and container_of() to work with CO-RE"

  [ Ubuntu: 6.5.0-2.2 ]

  * mantic/linux: 6.5.0-2.2 -proposed tracker (LP: #2033240)
  * Soundwire support for Dell SKU0C87 devices (LP: #2029281)
    - SAUCE: ASoC: Intel: soc-acpi: add support for Dell SKU0C87 devices
  * Fix numerous AER related issues (LP: #2033025)
    - SAUCE: PCI/AER: Disable AER service during suspend, again
    - SAUCE: PCI/DPC: Disable DPC service during suspend, again
  * Support Realtek RTL8852CE WiFi 6E/BT Combo (LP: #2025672)
    - wifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()
    - Bluetooth: btrtl: Load FW v2 otherwise FW v1 for RTL8852C
  * Rebase to v6.5

  [ Ubuntu: 6.5.0-1.1 ]

  * mantic/linux: 6.5.0-1.1 -proposed tracker (LP: #2032750)
  * Packaging resync (LP: #1786013)
    - [Packaging] resync update-dkms-versions helper
    - [Packaging] update variants
    - debian/dkms-versions -- update from kernel-versions (main/d2023.07.26)
  * ceph: support idmapped mounts (LP: #2032959)
    - SAUCE: libceph: add spinlock around osd->o_requests
    - SAUCE: libceph: define struct ceph_sparse_extent and add some helpers
    - SAUCE: libceph: new sparse_read op, support sparse reads on msgr2 crc
      codepath
    - SAUCE: libceph: support sparse reads on msgr2 secure codepath
    - SAUCE: libceph: add sparse read support to msgr1
    - SAUCE: libceph: add sparse read support to OSD client
    - SAUCE: ceph: add new mount option to enable sparse reads
    - SAUCE: ceph: preallocate inode for ops that may create one
    - SAUCE: ceph: make ceph_msdc_build_path use ref-walk
    - SAUCE: libceph: add new iov_iter-based ceph_msg_data_type and
      ceph_osd_data_type
    - SAUCE: ceph: use osd_req_op_extent_...

Read more...

Changed in linux-oem-6.5 (Ubuntu Jammy):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.