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: <20181123183503.v3gl42innv4zbilw@xylophone.i.decadent.org.uk>
Date:   Fri, 23 Nov 2018 18:35:03 +0000
From:   Ben Hutchings <ben.hutchings@...ethink.co.uk>
To:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] selftests/bpf: Add the ability to test for a log message
 on success

This is needed to test that code is being patched when it should be.

Signed-off-by: Ben Hutchings <ben.hutchings@...ethink.co.uk>
---
 tools/testing/selftests/bpf/test_verifier.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 0f3f97a401c9..e71b7f2e5f17 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -76,6 +76,8 @@ struct bpf_test {
 	int fixup_percpu_cgroup_storage[MAX_FIXUPS];
 	const char *errstr;
 	const char *errstr_unpriv;
+	const char *infostr;
+	const char *infostr_unpriv;
 	uint32_t retval, retval_unpriv;
 	enum {
 		UNDEF,
@@ -14232,7 +14234,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 	int prog_len, prog_type = test->prog_type;
 	struct bpf_insn *prog = test->insns;
 	int map_fds[MAX_NR_MAPS];
-	const char *expected_err;
+	const char *expected_err, *expected_info;
 	uint32_t expected_val;
 	uint32_t retval;
 	int i, err;
@@ -14253,6 +14255,8 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 		       test->result_unpriv : test->result;
 	expected_err = unpriv && test->errstr_unpriv ?
 		       test->errstr_unpriv : test->errstr;
+	expected_info = unpriv && test->infostr_unpriv ?
+			test->infostr_unpriv : test->infostr;
 	expected_val = unpriv && test->retval_unpriv ?
 		       test->retval_unpriv : test->retval;
 
@@ -14272,6 +14276,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 			       strerror(errno));
 			goto fail_log;
 		}
+		if (expected_info && !strstr(bpf_vlog, expected_info)) {
+			printf("FAIL\nMissing expected info message!\n\tEXP: %s\n\tRES: %s\n",
+			      expected_info, bpf_vlog);
+			goto fail_log;
+		}
 	} else {
 		if (fd_prog >= 0) {
 			printf("FAIL\nUnexpected success to load!\n");
-- 
Ben Hutchings, Software Developer                         Codethink Ltd
https://www.codethink.co.uk/                 Dale House, 35 Dale Street
                                     Manchester, M1 2HF, United Kingdom


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ