Commit 56e1a504 authored by Ilya Leoshkevich's avatar Ilya Leoshkevich Committed by Alexei Starovoitov

selftests/bpf: Fix verify_pkcs7_sig on s390x

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: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Link: https://lore.kernel.org/r/20230128000650.1516334-10-iii@linux.ibm.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 98e13848
...@@ -61,6 +61,9 @@ static bool kfunc_not_supported; ...@@ -61,6 +61,9 @@ static bool kfunc_not_supported;
static int libbpf_print_cb(enum libbpf_print_level level, const char *fmt, static int libbpf_print_cb(enum libbpf_print_level level, const char *fmt,
va_list args) 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")) if (strcmp(fmt, "libbpf: extern (func ksym) '%s': not found in kernel or module BTFs\n"))
return 0; return 0;
......
...@@ -59,10 +59,14 @@ int BPF_PROG(bpf, int cmd, union bpf_attr *attr, unsigned int size) ...@@ -59,10 +59,14 @@ int BPF_PROG(bpf, int cmd, union bpf_attr *attr, unsigned int size)
if (!data_val) if (!data_val)
return 0; return 0;
bpf_probe_read(&value, sizeof(value), &attr->value); ret = bpf_probe_read_kernel(&value, sizeof(value), &attr->value);
if (ret)
bpf_copy_from_user(data_val, sizeof(struct data), return ret;
(void *)(unsigned long)value);
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)) if (data_val->data_len > sizeof(data_val->data))
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment