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: <1238664979.8530.5723.camel@twins>
Date:	Thu, 02 Apr 2009 11:36:19 +0200
From:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
To:	Paul Mackerras <paulus@...ba.org>
Cc:	Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org,
	Mike Galbraith <efault@....de>,
	Arjan van de Ven <arjan@...radead.org>,
	Wu Fengguang <fengguang.wu@...el.com>
Subject: Re: [PATCH 2/9] perf_counter: fix update_userpage()

On Thu, 2009-04-02 at 20:15 +1100, Paul Mackerras wrote:
> Peter Zijlstra writes:
> 
> > > That means that we don't need any CPU memory barriers on either side.
> > > All the kernel needs to do is to increment `lock' when it updates
> > > things, and the user side can be:
> > > 
> > > 	do {
> > > 		seq = pc->lock;
> > > 		index = pc->index;
> > > 		offset = pc->offset;
> > > 		barrier();
> > > 	} while (pc->lock != seq);
> > > 
> > > and all that's needed is a compiler barrier to stop the compiler from
> > > optimizing too much.
> > 
> > Can this work at all?
> > 
> > I mean, user-space could get preempted/rescheduled after we read the
> > mmap() data using that seqlock and before we actually did the read-pmc
> > bit.
> > 
> > In that case, the counter can have changed underneath us and we're
> > reading rubbish.
> 
> Good point.  This should work, though:
> 
> 	do {
> 		seq = pc->lock;
> 		barrier();
> 		value = read_pmc(pc->index) + pc->offset;
> 		barrier();
> 	} while (pc->lock != seq);
> 	return value;

I don't think you need the first barrier(), all you need to avoid is it
reusing the first pc->lock read, so one should suffice.

Also, you need to handle the !pc->index case.

But yeah.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ