[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230324045842.729719-1-xukuohai@huaweicloud.com>
Date: Fri, 24 Mar 2023 00:58:40 -0400
From: Xu Kuohai <xukuohai@...weicloud.com>
To: bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
John Fastabend <john.fastabend@...il.com>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>
Subject: [PATCH bpf-next v2 0/2] bpf: add bound tracking for BPF_MOD
From: Xu Kuohai <xukuohai@...wei.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 %= 1 // 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.
v2:
- fix build warning reported by kernel test robot <lkp@...el.com> [0]
- add two more cases and update commit message
[0] https://lore.kernel.org/oe-kbuild-all/202303060036.zK05OC5M-lkp@intel.com
v1: https://lore.kernel.org/bpf/20230306033119.2634976-1-xukuohai@huaweicloud.com
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 | 320 +++++++++++++++++++++
2 files changed, 413 insertions(+), 5 deletions(-)
create mode 100644 tools/testing/selftests/bpf/verifier/mod.c
--
2.30.2
Powered by blists - more mailing lists