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:   Thu, 11 Jan 2018 21:27:07 +0000
From:   "Liang, Kan" <kan.liang@...el.com>
To:     Jiri Olsa <jolsa@...hat.com>
CC:     "acme@...nel.org" <acme@...nel.org>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "wangnan0@...wei.com" <wangnan0@...wei.com>,
        "jolsa@...nel.org" <jolsa@...nel.org>,
        "namhyung@...nel.org" <namhyung@...nel.org>,
        "ak@...ux.intel.com" <ak@...ux.intel.com>,
        "yao.jin@...ux.intel.com" <yao.jin@...ux.intel.com>
Subject: RE: [PATCH V3 03/12] perf mmap: discard 'prev' in perf_mmap__read

> On Thu, Dec 21, 2017 at 10:08:45AM -0800, kan.liang@...el.com wrote:
> > From: Kan Liang <kan.liang@...el.com>
> >
> > 'start' and 'prev' are duplicate in perf_mmap__read()
> >
> > Use 'map->prev' to replace 'start' in perf_mmap__read_*().
> >
> > Suggested-by: Wang Nan <wangnan0@...wei.com>
> > Signed-off-by: Kan Liang <kan.liang@...el.com>
> > ---
> >  tools/perf/util/mmap.c | 28 ++++++++++------------------
> >  1 file changed, 10 insertions(+), 18 deletions(-)
> >
> > diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
> > index 3fd4f3c..a844a2f 100644
> > --- a/tools/perf/util/mmap.c
> > +++ b/tools/perf/util/mmap.c
> > @@ -22,29 +22,27 @@ size_t perf_mmap__mmap_len(struct perf_mmap
> *map)
> >
> >  /* When check_messup is true, 'end' must points to a good entry */
> >  static union perf_event *perf_mmap__read(struct perf_mmap *map,
> > -					 u64 start, u64 end, u64 *prev)
> > +					 u64 *start, u64 end)
> >  {
> >  	unsigned char *data = map->base + page_size;
> >  	union perf_event *event = NULL;
> > -	int diff = end - start;
> > +	int diff = end - *start;
> 
> I'd like more if the arg was pointer, like 'u64 *startp' and you
> kept using the 'u64 start' value in the body.. but can't see any
> technical benefit behind it to force it ;-)
>

I will rename it as startp in V4.

Thanks,
Kan

 
> jirka
> 
> >
> >  	if (diff >= (int)sizeof(event->header)) {
> >  		size_t size;
> >
> > -		event = (union perf_event *)&data[start & map->mask];
> > +		event = (union perf_event *)&data[*start & map->mask];
> >  		size = event->header.size;
> >
> > -		if (size < sizeof(event->header) || diff < (int)size) {
> > -			event = NULL;
> > -			goto broken_event;
> > -		}
> > +		if (size < sizeof(event->header) || diff < (int)size)
> > +			return NULL;
> >
> >  		/*
> >  		 * Event straddles the mmap boundary -- header should
> always
> >  		 * be inside due to u64 alignment of output.
> >  		 */
> > -		if ((start & map->mask) + size != ((start + size) & map->mask))
> {
> > -			unsigned int offset = start;
> > +		if ((*start & map->mask) + size != ((*start + size) & map-
> >mask)) {
> > +			unsigned int offset = *start;
> >  			unsigned int len = min(sizeof(*event), size), cpy;
> >  			void *dst = map->event_copy;
> >
> > @@ -59,20 +57,15 @@ static union perf_event *perf_mmap__read(struct
> perf_mmap *map,
> >  			event = (union perf_event *)map->event_copy;
> >  		}
> >
> > -		start += size;
> > +		*start += size;
> >  	}
> >
> > -broken_event:
> > -	if (prev)
> > -		*prev = start;
> > -
> >  	return event;
> >  }
> 
> SNIP

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ