]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
selftests/bpf: Fix verify_pkcs7_sig on s390x
authorIlya Leoshkevich <iii@linux.ibm.com>
Sat, 28 Jan 2023 00:06:28 +0000 (01:06 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 28 Jan 2023 20:30:08 +0000 (12:30 -0800)
Use bpf_probe_read_kernel() instead of bpf_probe_read(), which is not
defined on all architectures.

While at it, improve the error handling: do not hide the verifier log,
and check the return values of bpf_probe_read_kernel() and
bpf_copy_from_user().

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Link: https://lore.kernel.org/r/20230128000650.1516334-10-iii@linux.ibm.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/verify_pkcs7_sig.c
tools/testing/selftests/bpf/progs/test_verify_pkcs7_sig.c

index 579d6ee83ce01154c7817f2ae902ce84c051f448..dd7f2bc70048c9469a6cb544c40e2e4e41be3306 100644 (file)
@@ -61,6 +61,9 @@ static bool kfunc_not_supported;
 static int libbpf_print_cb(enum libbpf_print_level level, const char *fmt,
                           va_list args)
 {
+       if (level == LIBBPF_WARN)
+               vprintf(fmt, args);
+
        if (strcmp(fmt, "libbpf: extern (func ksym) '%s': not found in kernel or module BTFs\n"))
                return 0;
 
index ce419304ff1f5e09a398041b804f39d3c8d5401d..7748cc23de8a903ec30f3cd654577775ccfb4983 100644 (file)
@@ -59,10 +59,14 @@ int BPF_PROG(bpf, int cmd, union bpf_attr *attr, unsigned int size)
        if (!data_val)
                return 0;
 
-       bpf_probe_read(&value, sizeof(value), &attr->value);
-
-       bpf_copy_from_user(data_val, sizeof(struct data),
-                          (void *)(unsigned long)value);
+       ret = bpf_probe_read_kernel(&value, sizeof(value), &attr->value);
+       if (ret)
+               return ret;
+
+       ret = bpf_copy_from_user(data_val, sizeof(struct data),
+                                (void *)(unsigned long)value);
+       if (ret)
+               return ret;
 
        if (data_val->data_len > sizeof(data_val->data))
                return -EINVAL;