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:   Wed, 18 Mar 2020 10:34:35 -0300
From:   Arnaldo Carvalho de Melo <acme@...hat.com>
To:     Jiri Olsa <jolsa@...hat.com>
Cc:     zhe.he@...driver.com, jolsa@...nel.org, ak@...ux.intel.com,
        meyerk@....com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf: Add NULL pointer check for cpu_map iteration and
 NULL assignment for all_cpus.

Em Wed, Mar 18, 2020 at 11:32:24AM +0100, Jiri Olsa escreveu:
> On Sun, Mar 08, 2020 at 06:59:17PM +0800, zhe.he@...driver.com wrote:
> > From: He Zhe <zhe.he@...driver.com>
> > 
> > NULL pointer may be passed to perf_cpu_map__cpu and then cause crash,
> > such as the one commit cb71f7d43ece ("libperf: Setup initial evlist::all_cpus value")
> > fix.
> > 
> > Signed-off-by: He Zhe <zhe.he@...driver.com>
> 
> Acked-by: Jiri Olsa <jolsa@...hat.com>
> 
> thanks,
> jirka
> 
> > ---
> >  tools/perf/lib/cpumap.c | 2 +-
> >  tools/perf/lib/evlist.c | 1 +
> >  2 files changed, 2 insertions(+), 1 deletion(-)

this is in tools/lib/perf/ for some time already, I'll do the changes
there, thanks,

- Arnaldo

> > 
> > diff --git a/tools/perf/lib/cpumap.c b/tools/perf/lib/cpumap.c
> > index f93f4e7..ca02150 100644
> > --- a/tools/perf/lib/cpumap.c
> > +++ b/tools/perf/lib/cpumap.c
> > @@ -247,7 +247,7 @@ struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list)
> >  
> >  int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx)
> >  {
> > -	if (idx < cpus->nr)
> > +	if (cpus && idx < cpus->nr)
> >  		return cpus->map[idx];
> >  
> >  	return -1;
> > diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c
> > index 5b9f2ca..f87a239 100644
> > --- a/tools/perf/lib/evlist.c
> > +++ b/tools/perf/lib/evlist.c
> > @@ -127,6 +127,7 @@ void perf_evlist__exit(struct perf_evlist *evlist)
> >  	perf_cpu_map__put(evlist->cpus);
> >  	perf_thread_map__put(evlist->threads);
> >  	evlist->cpus = NULL;
> > +	evlist->all_cpus = NULL;
> >  	evlist->threads = NULL;
> >  	fdarray__exit(&evlist->pollfd);
> >  }
> > -- 
> > 2.7.4
> > 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ