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:	Sun, 15 Oct 2006 15:51:09 +0200
From:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
To:	Nick Piggin <npiggin@...e.de>
Cc:	Linux Memory Management <linux-mm@...ck.org>,
	Neil Brown <neilb@...e.de>,
	Anton Altaparmakov <aia21@....ac.uk>,
	Chris Mason <chris.mason@...cle.com>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...l.org>
Subject: Re: [patch 6/6] mm: fix pagecache write deadlocks


> > > +		/*
> > > +		 * Must not enter the pagefault handler here, because we hold
> > > +		 * the page lock, so we might recursively deadlock on the same
> > > +		 * lock, or get an ABBA deadlock against a different lock, or
> > > +		 * against the mmap_sem (which nests outside the page lock).
> > > +		 * So increment preempt count, and use _atomic usercopies.
> > > +		 */
> > > +		inc_preempt_count();
> > >  		if (likely(nr_segs == 1))
> > > -			copied = filemap_copy_from_user(page, offset,
> > > +			copied = filemap_copy_from_user_atomic(page, offset,
> > >  							buf, bytes);
> > >  		else
> > > -			copied = filemap_copy_from_user_iovec(page, offset,
> > > -						cur_iov, iov_offset, bytes);
> > > +			copied = filemap_copy_from_user_iovec_atomic(page,
> > > +						offset, cur_iov, iov_offset,
> > > +						bytes);
> > > +		dec_preempt_count();
> > > +
> > 
> > Why use raw {inc,dec}_preempt_count() and not
> > preempt_{disable,enable}()? Is the compiler barrier not needed here? And
> > do we really want to avoid the preempt_check_resched()?
> 
> Counter to intuition, we actually don't mind being preempted here,
> but we do mind entering the (core) pagefault handler. Incrementing
> the preempt count causes the arch specific handler to bail out early
> before it takes any locks.
> 
> Clear as mud? Wrapping it in a better name might be an improvement?
> Or wrapping it into the copy*user_atomic functions themselves (which
> is AFAIK the only place we use it).

Right, but since you do inc the preempt_count you do disable preemption,
might as well check TIF_NEED_RESCHED when enabling preemption again.

Sticking it in the atomic copy functions does make sense to me.

-
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