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:	Mon, 9 Sep 2013 19:21:11 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Waiman Long <Waiman.Long@...com>,
	linux-fsdevel <linux-fsdevel@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	"Chandramouleeswaran, Aswin" <aswin@...com>,
	"Norton, Scott J" <scott.norton@...com>,
	George Spelvin <linux@...izon.com>,
	John Stoffel <john@...ffel.org>
Subject: Re: [PATCH v4 1/1] dcache: Translating dentry into pathname without
 taking rename_lock

On Mon, Sep 09, 2013 at 07:06:04PM +0100, Al Viro wrote:
> I like my proposal for the set of primitives better:
> 
> static inline bool seqretry_and_lock(seqlock_t *lock, unsigned *seq):
> {
>         if ((*seq & 1) || !read_seqretry(lock, *seq))
>                 return true;
>         *seq |= 1;
>         write_seqlock(lock);
>         return false;
> }
> 
> static inline void seqretry_done(seqlock_t *lock, unsigned seq)
> {
>         if (seq & 1)
>                 write_sequnlock(lock);
> }
> 
> with the prepend_path() and friends becoming
> 
> 	rcu_read_lock();
> 	seq = read_seqbegin(&rename_lock);
> again:
> 	....
> 	if (!seqretry_and_lock(&rename_lock, seq))
> 		goto again;	/* now as writer */
> 	seqretry_done(&rename_lock, seq);
> 	rcu_read_unlock();

Actually, it's better for prepend_path() as well, because it's actually
 
	rcu_read_lock();
	seq = read_seqbegin(&rename_lock);
again:
	....
	if (error)
		goto done;
	....
	if (!seqretry_and_lock(&rename_lock, seq))
		goto again;	/* now as writer */
done:
	seqretry_done(&rename_lock, seq);
	rcu_read_unlock();

Posted variant will sometimes hit the following path:
	* seq_readlock()
	* start generating the output
	* hit an error
[another process has taken and released rename_lock for some reason]
	* hit read_seqretry_and_unlock(), which returns 1.
	* retry everything with seq_writelock(), despite the error.

It's not too horrible (we won't be looping indefinitely, ignoring error
all along), but it's certainly subtle enough...
--
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