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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <65863961-d443-0ce7-0659-659f1bf76463@iogearbox.net>
Date:   Mon, 19 Nov 2018 23:36:14 +0100
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Stanislav Fomichev <sdf@...gle.com>, netdev@...r.kernel.org,
        ast@...nel.org
Cc:     vladum@...gle.com
Subject: Re: [PATCH bpf-next] bpf: libbpf: retry map creation without the name

On 11/19/2018 10:35 PM, Stanislav Fomichev wrote:
> Since commit 88cda1c9da02 ("bpf: libbpf: Provide basic API support
> to specify BPF obj name"), libbpf unconditionally sets bpf_attr->name
> for maps. Pre v4.14 kernels don't know about map names and return an
> error about unexpected non-zero data. Retry sys_bpf without a map
> name to cover older kernels.

Looks good, small nit below:

> Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
> ---
>  tools/lib/bpf/bpf.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 03f9bcc4ef50..673175bc06ee 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -69,6 +69,7 @@ int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr)
>  {
>  	__u32 name_len = create_attr->name ? strlen(create_attr->name) : 0;
>  	union bpf_attr attr;
> +	int ret;
>  
>  	memset(&attr, '\0', sizeof(attr));
>  
> @@ -86,7 +87,15 @@ int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr)
>  	attr.map_ifindex = create_attr->map_ifindex;
>  	attr.inner_map_fd = create_attr->inner_map_fd;
>  
> -	return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
> +	ret = sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
> +	if (ret < 0 && create_attr->name) {

Could you also check errno being EINVAL here so that we do not try to
confuse it with an error coming from insufficient memlock which is
EPERM in that case.

> +		/* Retry the same syscall, but without the name.
> +		 * Pre v4.14 kernels don't support map names.
> +		 */
> +		memset(attr.map_name, 0, sizeof(attr.map_name));
> +		return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
> +	}
> +	return ret;
>  }
>  
>  int bpf_create_map_node(enum bpf_map_type map_type, const char *name,
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ