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: <CAPhsuW7gg-hdOSrUZpQHoVUgZs3Uj+cXt7CmXpKgoTWSTDgRog@mail.gmail.com>
Date: Mon, 22 Sep 2025 16:17:14 +0200
From: Song Liu <song@...nel.org>
To: liujing <liujing@...s.chinamobile.com>
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org, 
	martin.lau@...ux.dev, eddyz87@...il.com, yonghong.song@...ux.dev, 
	john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me, 
	haoluo@...gle.com, jolsa@...nel.org, bpf@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bpf: The main function in the file tools/bpf/bpf_dbg.c
 does not call fclose() to close the opened files at the end, leading to
 issues such as memory leaks.

A few logistics:

1. Please tag your patch with [PATCH bpf-next <version>] or
[PATCH bpf <version>] so that the CI can apply it to the right tree.
2. Please write better commit log. The subject should include "what";
while the "why" part should go to the later part of the commit log.
For example:

bpf_debug: Close opened files

Add fclose calls to the main function to openeed files, so that we
do not memory leak.

On Mon, Sep 22, 2025 at 10:22 AM liujing <liujing@...s.chinamobile.com> wrote:
>
> Signed-off-by: liujing <liujing@...s.chinamobile.com>

3. Please sign off with your full real name.

> ---
>  tools/bpf/bpf_dbg.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/tools/bpf/bpf_dbg.c b/tools/bpf/bpf_dbg.c
> index 00e560a17baf..ac834b6d78a8 100644
> --- a/tools/bpf/bpf_dbg.c
> +++ b/tools/bpf/bpf_dbg.c
> @@ -1388,11 +1388,18 @@ static int run_shell_loop(FILE *fin, FILE *fout)
>  int main(int argc, char **argv)
>  {
>         FILE *fin = NULL, *fout = NULL;
> +       int result;
>
>         if (argc >= 2)
>                 fin = fopen(argv[1], "r");
>         if (argc >= 3)
>                 fout = fopen(argv[2], "w");
>
> -       return run_shell_loop(fin ? : stdin, fout ? : stdout);
> +       result = run_shell_loop(fin ? : stdin, fout ? : stdout);
> +
> +       if (fin && fin != stdin)

We can simply do "if (fin)", right?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ