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]
Date:   Mon, 9 Nov 2020 11:51:47 +0100
From:   Michal Rostecki <mrostecki@...nsuse.org>
To:     Wang Hai <wanghai38@...wei.com>, ast@...nel.org,
        daniel@...earbox.net, kafai@...com, songliubraving@...com,
        yhs@...com, andrii@...nel.org, john.fastabend@...il.com,
        kpsingh@...omium.org, toke@...hat.com, quentin@...valent.com,
        danieltimlee@...il.com
Cc:     bpf@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf] tools: bpftool: Add missing close before bpftool net
 attach exit

On 11/9/20 8:04 AM, Wang Hai wrote:
> progfd is created by prog_parse_fd(), before 'bpftool net attach' exit,
> it should be closed.
> 
> Fixes: 04949ccc273e ("tools: bpftool: add net attach command to attach XDP on interface")
> Signed-off-by: Wang Hai <wanghai38@...wei.com>
> ---
>   tools/bpf/bpftool/net.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tools/bpf/bpftool/net.c b/tools/bpf/bpftool/net.c
> index 910e7bac6e9e..3e9b40e64fb0 100644
> --- a/tools/bpf/bpftool/net.c
> +++ b/tools/bpf/bpftool/net.c
> @@ -600,12 +600,14 @@ static int do_attach(int argc, char **argv)
>   	if (err < 0) {
>   		p_err("interface %s attach failed: %s",
>   		      attach_type_strings[attach_type], strerror(-err));
> +		close(progfd);
>   		return err;
>   	}
>   
>   	if (json_output)
>   		jsonw_null(json_wtr);
>   
> +	close(progfd);
>   	return 0;
>   }
>   

Nit - wouldn't it be better to create a `cleanup`/`out` section before 
return and use goto, to avoid copying the `close` call?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ