public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/2] bpf: Add range tracking for BPF_DIV and BPF_MOD
@ 2026-01-16 10:32 Yazhou Tang
  2026-01-16 10:32 ` [PATCH bpf-next v4 1/2] " Yazhou Tang
  2026-01-16 10:32 ` [PATCH bpf-next v4 2/2] selftests/bpf: Add tests for BPF_DIV and BPF_MOD range tracking Yazhou Tang
  0 siblings, 2 replies; 7+ messages in thread
From: Yazhou Tang @ 2026-01-16 10:32 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
	yonghong.song, kpsingh, sdf, haoluo, jolsa, tangyazhou518,
	shenghaoyuan0928, ziye

From: Yazhou Tang <tangyazhou518@outlook.com>

Add range tracking (interval analysis) for BPF_DIV and BPF_MOD when
divisor is constant. Please see commit log of 1/2 for more details.

---

Changes v3 => v4:
1. Remove verbose helper functions for "division by zero" handling. (Alexei)
2. Put all "reset" logic in one place for clarity, and add 2 helper
   function `__reset_reg64_and_tnum` and `__reset_reg32_and_tnum` to
   reduce code duplication. (Alexei)
3. Update all multi-line comments to follow the standard kernel style. (Alexei)
4. Add new test cases to cover strictly positive and strictly negative
   divisor scenarios in SDIV and SMOD analysis. (Alexei)
5. Fixup a typo in SDIV analysis functions.

v3: https://lore.kernel.org/bpf/20260113103552.3435695-1-tangyazhou@zju.edu.cn/

Changes v2 => v3:
1. Fixup a bug in `adjust_scalar_min_max_vals` function that lead to
   incorrect range results. (Syzbot)
2. Remove tnum analysis logic. (Alexei)
3. Only handle "constant divisor" case. (Alexei)
4. Add BPF_MOD range analysis logic.
5. Update selftests accordingly.
6. Add detailed code comments and improve commit messages. (Yonghong)

v2: https://lore.kernel.org/bpf/20251223091120.2413435-1-tangyazhou@zju.edu.cn/

Changes v1 => v2:
1. Fixed 2 bugs in sdiv32 analysis logic and corrected the associated
   selftest cases. (AI reviewer)
2. Renamed `tnum_bottom` to `tnum_empty` for better clarity, and updated
   commit message to explain its role in signed BPF_DIV analysis.

v1:
https://lore.kernel.org/bpf/tencent_717092CD734D050CCD93401CA624BB3C8307@qq.com/
https://lore.kernel.org/bpf/tencent_7C98FAECA40C98489ACF4515CE346F031509@qq.com/

Yazhou Tang (2):
  bpf: Add range tracking for BPF_DIV and BPF_MOD
  selftests/bpf: Add tests for BPF_DIV and BPF_MOD range tracking

 kernel/bpf/verifier.c                         |  299 +++++
 .../selftests/bpf/prog_tests/verifier.c       |    2 +
 .../bpf/progs/verifier_div_mod_bounds.c       | 1149 +++++++++++++++++
 .../bpf/progs/verifier_value_illegal_alu.c    |    7 +-
 .../testing/selftests/bpf/verifier/precise.c  |    4 +-
 5 files changed, 1456 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_div_mod_bounds.c

-- 
2.52.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-19  8:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-16 10:32 [PATCH bpf-next v4 0/2] bpf: Add range tracking for BPF_DIV and BPF_MOD Yazhou Tang
2026-01-16 10:32 ` [PATCH bpf-next v4 1/2] " Yazhou Tang
2026-01-16 18:44   ` kernel test robot
2026-01-17 17:22   ` Alexei Starovoitov
2026-01-19  8:30     ` Yazhou Tang
2026-01-17 17:59   ` kernel test robot
2026-01-16 10:32 ` [PATCH bpf-next v4 2/2] selftests/bpf: Add tests for BPF_DIV and BPF_MOD range tracking Yazhou Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox