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: <6f975e8c-34f5-4bcb-d99d-d1977866bedf@iogearbox.net>
Date:   Mon, 27 Apr 2020 23:37:03 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Mao Wenan <maowenan@...wei.com>, ast@...nel.org, kafai@...com,
        songliubraving@...com, yhs@...com, andriin@...com,
        john.fastabend@...il.com, kpsingh@...omium.org,
        andrii.nakryiko@...il.com, dan.carpenter@...cle.com
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH bpf-next v3 1/2] bpf: Change error code when ops is NULL

On 4/26/20 8:36 AM, Mao Wenan wrote:
> There is one error printed when use BPF_MAP_TYPE_SOCKMAP to create map:
> libbpf: failed to create map (name: 'sock_map'): Invalid argument(-22)
> 
> This is because CONFIG_BPF_STREAM_PARSER is not set, and
> bpf_map_types[type] return invalid ops. It is not clear to show the
> cause of config missing with return code -EINVAL.
> 
> Signed-off-by: Mao Wenan <maowenan@...wei.com>
> ---
>   kernel/bpf/syscall.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index d85f37239540..8ae78c98d91e 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -113,7 +113,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
>   	type = array_index_nospec(type, ARRAY_SIZE(bpf_map_types));
>   	ops = bpf_map_types[type];
>   	if (!ops)
> -		return ERR_PTR(-EINVAL);
> +		return ERR_PTR(-EOPNOTSUPP);
>   
>   	if (ops->map_alloc_check) {
>   		err = ops->map_alloc_check(attr);
> 

Unless I'm missing the use-case, why not using bpftool's feature probe to check for
availability (alternatively via 'feature probe kernel macros' if you need this into
inside the BPF prog for ifdef etc)?

   bpftool feature probe kernel | grep sockmap
   eBPF map_type sockmap is NOT available

Thanks,
Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ