linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: add bound tracking for BPF_MOD
@ 2023-03-06  3:31 Xu Kuohai
  2023-03-06  3:31 ` [PATCH bpf-next 1/2] " Xu Kuohai
  2023-03-06  3:31 ` [PATCH bpf-next 2/2] selftests/bpf: check if verifier tracks dst_reg bound " Xu Kuohai
  0 siblings, 2 replies; 5+ messages in thread
From: Xu Kuohai @ 2023-03-06  3:31 UTC (permalink / raw)
  To: bpf, linux-kselftest, linux-kernel
  Cc: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Mykola Lysenko,
	Shuah Khan

From: Xu Kuohai <xukuohai@huawei.com>

dst_reg is marked as unknown when BPF_MOD instruction is verified, causing
the following bpf prog to be incorrectly rejected.

0: r0 = 0
1: r0 %= 10   // r0 is marked as unknown
2: r1 = 0
3: r1 += 1
4: if r1 < r0 goto pc-2 // verifier concludes the loop is unbounded
5: exit

To teach verifier to accept the above prog, this series adds bound tracking
for BPF_MOD.

Xu Kuohai (2):
  bpf: add bound tracking for BPF_MOD
  selftests/bpf: check if verifier tracks dst_reg bound for BPF_MOD

 kernel/bpf/verifier.c                      |  98 +++++++-
 tools/testing/selftests/bpf/verifier/mod.c | 247 +++++++++++++++++++++
 2 files changed, 340 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/verifier/mod.c

-- 
2.30.2


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

end of thread, other threads:[~2023-03-05 18:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06  3:31 [PATCH bpf-next 0/2] bpf: add bound tracking for BPF_MOD Xu Kuohai
2023-03-06  3:31 ` [PATCH bpf-next 1/2] " Xu Kuohai
2023-03-05 16:48   ` kernel test robot
2023-03-05 18:00   ` kernel test robot
2023-03-06  3:31 ` [PATCH bpf-next 2/2] selftests/bpf: check if verifier tracks dst_reg bound " Xu Kuohai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).