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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 11 Jan 2018 21:26:28 +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 02/12] perf mmap: factor out function to find
 ringbuffer position

 
> On Thu, Dec 21, 2017 at 10:08:44AM -0800, kan.liang@...el.com wrote:
> 
> SNIP
> 
> > +/*
> > + * Report the start and end of the available data in ringbuffer
> > + */
> > +int perf_mmap__read_init(struct perf_mmap *map, bool overwrite,
> > +			 u64 *start, u64 *end)
> >  {
> > -	u64 head = perf_mmap__read_head(md);
> > -	u64 old = md->prev;
> > -	u64 end = head, start = old;
> > -	unsigned char *data = md->base + page_size;
> > +	u64 head = perf_mmap__read_head(map);
> > +	u64 old = map->prev;
> > +	unsigned char *data = map->base + page_size;
> >  	unsigned long size;
> > -	void *buf;
> > -	int rc = 0;
> >
> > -	start = overwrite ? head : old;
> > -	end = overwrite ? old : head;
> > +	/*
> > +	 * Check if event was unmapped due to a POLLHUP/POLLERR.
> > +	 */
> > +	if (!refcount_read(&map->refcnt))
> > +		return -EINVAL;
> >
> > -	if (start == end)
> > -		return 0;
> > +	*start = overwrite ? head : old;
> > +	*end = overwrite ? old : head;
> >
> > -	size = end - start;
> > -	if (size > (unsigned long)(md->mask) + 1) {
> > +	if (*start == *end)
> > +		return -EAGAIN;
> > +
> > +	size = *end - *start;
> > +	if (size > (unsigned long)(map->mask) + 1) {
> >  		if (!overwrite) {
> >  			WARN_ONCE(1, "failed to keep up with mmap data.
> (warn only once)\n");
> >
> 
> I know you did not change this, but is this leg even possible
> in !overwrite mode? I think kernel will throw away the data,
> keep the head and wait for tail to be read by user..

Right, it should not happen in !overwrite mode. I guess it's just
sanity check.
It should not bring any problems.
I think I will still keep it for V4 if no objection? 

Thanks,
Kan

> 
> jirka
> 
> > -			md->prev = head;
> > -			perf_mmap__consume(md, overwrite);
> > -			return 0;
> > +			map->prev = head;
> > +			perf_mmap__consume(map, overwrite);
> > +			return -EAGAIN;
> 
> SNIP

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ