[RFC bpf-next v2 0/3] Improve signed ranges reasoning for BPF_AND

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



RFC because the selftests in the 3rd patch is failing and I couldn't
figure out what's going on, sending out for suggestion.

This is a follow up of Xu Kuohai's "Add BPF LSM return value range
check, BPF part" series[1], where the 5th patch "improve signed ranges
inference for BPF_AND" was omitting because further changes were
required. This series brough back that patch (with modifications as
requested), removed workaround, and bring back 'test 3'[2] from Xu Kuohai
that was also dropped.

Patch 1 add reasoning of signed ranges directly from previous signed
ranges during BPF_AND to the BPF verfier, which allowed better tracking
of signed range for situation like [-1, 0] & -13. See the patch for
complete detail.

Patch 2 and 3 are corresponding tests. Patch 2 brings back an omitted
test[2] from Xu Kuohai. Patch 3 add more specific test in
verifier_and.c.

1: https://lore.kernel.org/bpf/20240719110059.797546-1-xukuohai@xxxxxxxxxxxxxxx/
2: https://lore.kernel.org/bpf/20240719110059.797546-10-xukuohai@xxxxxxxxxxxxxxx/

Changes since v1:
- address comments
  - add code comment in scalar*_min_max_and() to better explaining the
    reasoning (Eduard, Alexei)
  - point out unsigned range are still propagated to signed range later
    in __reg_deduce_bounds() (Edward)
  - point out the fls(~v) special case in negative_bit_floor() (Edward)
- revert workaround added in 229d6db14942
- add additional tests
- v1 can be found at both
  - https://lore.kernel.org/bpf/20240719110059.797546-6-xukuohai@xxxxxxxxxxxxxxx/
  - https://lore.kernel.org/bpf/9505522b-de45-cf52-162b-76a3a52a6efe@xxxxxxxxx/

Shung-Hsi Yu (3):
  bpf, verifier: improve signed ranges inference for BPF_AND
  selftests/bpf: bring back verifier tests for bpf lsm
  selftests/bpf: add more verifier tests for signed range deduction of
    BPF_AND

 kernel/bpf/verifier.c                         | 105 ++++++++++++++----
 .../bpf/progs/test_libbpf_get_fd_by_id_opts.c |   1 -
 .../selftests/bpf/progs/verifier_and.c        |  56 ++++++++++
 .../selftests/bpf/progs/verifier_lsm.c        |  16 +++
 4 files changed, 157 insertions(+), 21 deletions(-)

-- 
2.47.0





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux