1. 14 Dec, 2023 19 commits
  2. 13 Dec, 2023 16 commits
  3. 12 Dec, 2023 5 commits
    • YiFei Zhu's avatar
      selftests/bpf: Relax time_tai test for equal timestamps in tai_forward · e1ba7f64
      YiFei Zhu authored
      We're observing test flakiness on an arm64 platform which might not
      have timestamps as precise as x86. The test log looks like:
      
        test_time_tai:PASS:tai_open 0 nsec
        test_time_tai:PASS:test_run 0 nsec
        test_time_tai:PASS:tai_ts1 0 nsec
        test_time_tai:PASS:tai_ts2 0 nsec
        test_time_tai:FAIL:tai_forward unexpected tai_forward: actual 1702348135471494160 <= expected 1702348135471494160
        test_time_tai:PASS:tai_gettime 0 nsec
        test_time_tai:PASS:tai_future_ts1 0 nsec
        test_time_tai:PASS:tai_future_ts2 0 nsec
        test_time_tai:PASS:tai_range_ts1 0 nsec
        test_time_tai:PASS:tai_range_ts2 0 nsec
        #199     time_tai:FAIL
      
      This patch changes ASSERT_GT to ASSERT_GE in the tai_forward assertion
      so that equal timestamps are permitted.
      
      Fixes: 64e15820 ("selftests/bpf: Add BPF-helper test for CLOCK_TAI access")
      Signed-off-by: default avatarYiFei Zhu <zhuyifei@google.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20231212182911.3784108-1-zhuyifei@google.com
      e1ba7f64
    • Andrei Matei's avatar
      bpf: Comment on check_mem_size_reg · 745e0311
      Andrei Matei authored
      This patch adds a comment to check_mem_size_reg -- a function whose
      meaning is not very transparent. The function implicitly deals with two
      registers connected by convention, which is not obvious.
      Signed-off-by: default avatarAndrei Matei <andreimatei1@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20231210225149.67639-1-andreimatei1@gmail.com
      745e0311
    • Yang Li's avatar
      bpf: Remove unused backtrack_state helper functions · 56c26d5a
      Yang Li authored
      The function are defined in the verifier.c file, but not called
      elsewhere, so delete the unused function.
      
      kernel/bpf/verifier.c:3448:20: warning: unused function 'bt_set_slot'
      kernel/bpf/verifier.c:3453:20: warning: unused function 'bt_clear_slot'
      kernel/bpf/verifier.c:3488:20: warning: unused function 'bt_is_slot_set'
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/bpf/20231212005436.103829-1-yang.lee@linux.alibaba.com
      
      Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7714
      56c26d5a
    • Manu Bretelle's avatar
      selftests/bpf: Fixes tests for filesystem kfuncs · f77d7956
      Manu Bretelle authored
      `fs_kfuncs.c`'s `test_xattr` would fail the test even when the
      filesystem did not support xattr, for instance when /tmp is mounted as
      tmpfs.
      
      This change checks errno when setxattr fail. If the failure is due to
      the operation being unsupported, we will skip the test (just like we
      would if verity was not enabled on the FS.
      
      Before the change, fs_kfuncs test would fail in test_axattr:
      
       $ vmtest -k $(make -s image_name) './tools/testing/selftests/bpf/test_progs -a fs_kfuncs'
       => bzImage
       ===> Booting
       [    0.000000] rcu:        RCU restricting CPUs from NR_CPUS=128 to
       nr_cpu_
       ===> Setting up VM
       ===> Running command
       [    4.157491] bpf_testmod: loading out-of-tree module taints kernel.
       [    4.161515] bpf_testmod: module verification failed: signature and/or
       required key missing - tainting kernel
       test_xattr:PASS:create_file 0 nsec
       test_xattr:FAIL:setxattr unexpected error: -1 (errno 95)
       #90/1    fs_kfuncs/xattr:FAIL
       #90/2    fs_kfuncs/fsverity:SKIP
       #90      fs_kfuncs:FAIL
      
       All error logs:
       test_xattr:PASS:create_file 0 nsec
       test_xattr:FAIL:setxattr unexpected error: -1 (errno 95)
       #90/1    fs_kfuncs/xattr:FAIL
       #90      fs_kfuncs:FAIL
      
       Summary: 0/0 PASSED, 1 SKIPPED, 1 FAILED
      
      Test plan:
      
        $ touch tmpfs_file && truncate -s 1G tmpfs_file && mkfs.ext4 tmpfs_file
        # /tmp mounted as tmpfs
        $ vmtest -k $(make -s image_name) './tools/testing/selftests/bpf/test_progs -a fs_kfuncs'
        => bzImage
        ===> Booting
        ===> Setting up VM
        ===> Running command
        WARNING! Selftests relying on bpf_testmod.ko will be skipped.
        Can't find bpf_testmod.ko kernel module: -2
        #90/1    fs_kfuncs/xattr:SKIP
        #90/2    fs_kfuncs/fsverity:SKIP
        #90      fs_kfuncs:SKIP
        Summary: 1/0 PASSED, 2 SKIPPED, 0 FAILED
        # /tmp mounted as ext4 with xattr enabled but not verity
        $ vmtest -k $(make -s image_name) 'mount -o loop tmpfs_file /tmp && \
          /tools/testing/selftests/bpf/test_progs -a fs_kfuncs'
        => bzImage
        ===> Booting
        ===> Setting up VM
        ===> Running command
        [    4.067071] loop0: detected capacity change from 0 to 2097152
        [    4.191882] EXT4-fs (loop0): mounted filesystem
        407ffa36-4553-4c8c-8c78-134443630f69 r/w with ordered data mode. Quota
        mode: none.
        WARNING! Selftests relying on bpf_testmod.ko will be skipped.
        Can't find bpf_testmod.ko kernel module: -2
        #90/1    fs_kfuncs/xattr:OK
        #90/2    fs_kfuncs/fsverity:SKIP
        #90      fs_kfuncs:OK (SKIP: 1/2)
        Summary: 1/1 PASSED, 1 SKIPPED, 0 FAILED
        $ tune2fs -O verity tmpfs_file
        # /tmp as ext4 with both xattr and verity enabled
        $ vmtest -k $(make -s image_name) 'mount -o loop tmpfs_file /tmp && \
          ./tools/testing/selftests/bpf/test_progs -a fs_kfuncs'
        => bzImage
        ===> Booting
        ===> Setting up VM
        ===> Running command
        [    4.291434] loop0: detected capacity change from 0 to 2097152
        [    4.460828] EXT4-fs (loop0): recovery complete
        [    4.468631] EXT4-fs (loop0): mounted filesystem
        7b4a7b7f-c442-4b06-9ede-254e63cceb52 r/w with ordered data mode. Quota
        mode: none.
        [    4.988074] fs-verity: sha256 using implementation "sha256-generic"
        WARNING! Selftests relying on bpf_testmod.ko will be skipped.
        Can't find bpf_testmod.ko kernel module: -2
        #90/1    fs_kfuncs/xattr:OK
        #90/2    fs_kfuncs/fsverity:OK
        #90      fs_kfuncs:OK
        Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
      
      Fixes: 341f06fd ("selftests/bpf: Add tests for filesystem kfuncs")
      Signed-off-by: default avatarManu Bretelle <chantr4@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/bpf/20231211180733.763025-1-chantr4@gmail.com
      f77d7956
    • Andrii Nakryiko's avatar
      bpf: use bitfields for simple per-subprog bool flags · 406a6fa4
      Andrii Nakryiko authored
      We have a bunch of bool flags for each subprog. Instead of wasting bytes
      for them, use bitfields instead.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20231204233931.49758-5-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      406a6fa4