lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240122075700.7120-3-yangtiezhu@loongson.cn>
Date: Mon, 22 Jan 2024 15:56:59 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Andrii Nakryiko <andrii@...nel.org>
Cc: Eduard Zingerman <eddyz87@...il.com>,
	John Fastabend <john.fastabend@...il.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Hou Tao <houtao@...weicloud.com>,
	Song Liu <song@...nel.org>,
	bpf@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH bpf-next v6 2/3] selftests/bpf: Copy insn_is_pseudo_func() into testing_helpers

insn_is_pseudo_func() will be used in test_verifier, the original idea is
to move it from libbpf.c to libbpf_internal.h and then include the header
to reuse this function, this just adds more internal code of libbpf used
by selftests. While we have allowed it in some cases to avoid duplication
of more complex logic, it is not justified in this case.

Since insn_is_pseudo_func() and its helper is_ldimm64_insn() are trivial
enough, just copy into testing_helpers.

Suggested-by: Andrii Nakryiko <andrii@...nel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
 tools/testing/selftests/bpf/testing_helpers.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/testing/selftests/bpf/testing_helpers.h b/tools/testing/selftests/bpf/testing_helpers.h
index d14de81727e6..cd77dce1b1da 100644
--- a/tools/testing/selftests/bpf/testing_helpers.h
+++ b/tools/testing/selftests/bpf/testing_helpers.h
@@ -54,4 +54,14 @@ int get_xlated_program(int fd_prog, struct bpf_insn **buf, __u32 *cnt);
 int testing_prog_flags(void);
 bool is_jit_enabled(void);
 
+static inline bool is_ldimm64_insn(struct bpf_insn *insn)
+{
+	return insn->code == (BPF_LD | BPF_IMM | BPF_DW);
+}
+
+static inline bool insn_is_pseudo_func(struct bpf_insn *insn)
+{
+	return is_ldimm64_insn(insn) && insn->src_reg == BPF_PSEUDO_FUNC;
+}
+
 #endif /* __TESTING_HELPERS_H */
-- 
2.42.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ