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: <Y1el0SXrk8paN1Zm@krava>
Date:   Tue, 25 Oct 2022 11:01:05 +0200
From:   Jiri Olsa <olsajiri@...il.com>
To:     Chuang Wang <nashuiliang@...il.com>
Cc:     stable@...r.kernel.org, Song Liu <song@...nel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <martin.lau@...ux.dev>,
        Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Hao Luo <haoluo@...gle.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Masami Hiramatsu <mhiramat@...nel.org>, bpf@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bpf: Clean up all resources when register_fprobe_ips
 returns an error

On Tue, Oct 25, 2022 at 04:06:28PM +0800, Chuang Wang wrote:
> When register_fprobe_ips returns an error, bpf_link_cleanup just cleans
> up bpf_link_primer's resources and forgets to clean up
> bpf_kprobe_multi_link, addrs, cookies.
> 
> So, by adding 'goto error', this ensures that all resources are cleaned
> up.
> 
> Cc: stable@...r.kernel.org
> Fixes: 0dcac2725406 ("bpf: Add multi kprobe link")
> Signed-off-by: Chuang Wang <nashuiliang@...il.com>
> ---
>  kernel/trace/bpf_trace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 1ed08967fb97..5b806ef20857 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -2778,7 +2778,7 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
>  	err = register_fprobe_ips(&link->fp, addrs, cnt);
>  	if (err) {
>  		bpf_link_cleanup(&link_primer);
> -		return err;
> +		goto error;

that should be taken care of bpf_kprobe_multi_link_dealloc,
through the fput path in bpf_link_cleanup

do you see any related memory leak like report in kmemleak?

jirka

>  	}
>  
>  	return bpf_link_settle(&link_primer);
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ