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] [day] [month] [year] [list]
Message-ID: <36fade92f6ed872d62c9fadecc88fd3b764a6423.camel@gmail.com>
Date: Thu, 11 Jul 2024 00:52:47 -0700
From: Eduard Zingerman <eddyz87@...il.com>
To: Ma Ke <make24@...as.ac.cn>, ast@...nel.org, daniel@...earbox.net, 
 andrii@...nel.org, martin.lau@...ux.dev, song@...nel.org,
 yonghong.song@...ux.dev,  john.fastabend@...il.com, kpsingh@...nel.org,
 sdf@...ichev.me, haoluo@...gle.com,  jolsa@...nel.org, mykolal@...com,
 shuah@...nel.org
Cc: bpf@...r.kernel.org, linux-kselftest@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bpf, selftests: fix a resource leak in main()

On Thu, 2024-07-11 at 15:44 +0800, Ma Ke wrote:
> The requested resources should be closed before return in main(), otherwise
> resource leak will occur. Add a check of cgroup_fd and close().

Note: it is better to group related patches to a patch-set.

> 
> Fixes: 4939b2847d26 ("bpf, selftests: Use single cgroup helpers for both test_sockmap/progs")
> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
>  tools/testing/selftests/bpf/test_dev_cgroup.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/test_dev_cgroup.c b/tools/testing/selftests/bpf/test_dev_cgroup.c
> index adeaf63cb6fa..e97fc061fab2 100644
> --- a/tools/testing/selftests/bpf/test_dev_cgroup.c
> +++ b/tools/testing/selftests/bpf/test_dev_cgroup.c
> @@ -81,5 +81,7 @@ int main(int argc, char **argv)
>  	cleanup_cgroup_environment();
>  
>  out:
> +	if (cgroup_fd >= 0)
> +		close(cgroup_fd);

This is a standalone program, and Linux closes file descriptors on process exit,
why do you think it's necessary to close the fd here?

>  	return error;
>  }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ