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: <20191016140856.GG22835@kernel.org>
Date:   Wed, 16 Oct 2019 11:08:56 -0300
From:   Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To:     Yunfeng Ye <yeyunfeng@...wei.com>
Cc:     Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>,
        peterz@...radead.org, mingo@...hat.com, mark.rutland@....com,
        alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
        namhyung@...nel.org, linux-kernel@...r.kernel.org,
        hushiyuan@...wei.com, linfeilong@...wei.com
Subject: Re: [PATCH] perf kmem: Fix memory leak in compact_gfp_flags()

Em Wed, Oct 16, 2019 at 09:19:54PM +0800, Yunfeng Ye escreveu:
> 
> 
> On 2019/10/16 21:09, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Oct 16, 2019 at 10:04:03AM -0300, Arnaldo Carvalho de Melo escreveu:
> >> Em Wed, Oct 16, 2019 at 04:38:45PM +0800, Yunfeng Ye escreveu:
> >>> The memory @orig_flags is allocated by strdup(), it is freed on the
> >>> normal path, but leak to free on the error path.
> >>
> >> Are you using some tool to find out these problems? Or is it just visual
> >> inspection?
> > 
> By a static code anaylsis tool which not an open source tool. thanks.

Ok, so please state that next time, just for the fullest possible
disclosure and for people to realize to what extent problems in the
kernel and in tooling hosted in the kernel is being fixed by such tools.

I.e. you don't need to release the tool, not even give out its name,
just something like:

"Found by internal static analysis tool."

Thanks,

- Arnaldo
 
> > Anyway, applied after adding this to the commit log message:
> > 
> > Fixes: 0e11115644b3 ("perf kmem: Print gfp flags in human readable string")
> > 
> ok, thanks.
> 
> > - Arnaldo
> >  
> >> - Arnaldo
> >>  
> >>> Fix this by adding free(orig_flags) on the error path.
> >>>
> >>> Signed-off-by: Yunfeng Ye <yeyunfeng@...wei.com>
> >>> ---
> >>>  tools/perf/builtin-kmem.c | 1 +
> >>>  1 file changed, 1 insertion(+)
> >>>
> >>> diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
> >>> index 1e61e353f579..9661671cc26e 100644
> >>> --- a/tools/perf/builtin-kmem.c
> >>> +++ b/tools/perf/builtin-kmem.c
> >>> @@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
> >>>  			new = realloc(new_flags, len + strlen(cpt) + 2);
> >>>  			if (new == NULL) {
> >>>  				free(new_flags);
> >>> +				free(orig_flags);
> >>>  				return NULL;
> >>>  			}
> >>>
> >>> -- 
> >>> 2.7.4.3
> >>
> >> -- 
> >>
> >> - Arnaldo
> > 

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ