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:	Tue, 8 Jul 2014 11:29:17 +0200
From:	Miklos Szeredi <miklos@...redi.hu>
To:	David Howells <dhowells@...hat.com>
Cc:	Sedat Dilek <sedat.dilek@...il.com>,
	"J. R. Okajima" <hooanon05g@...il.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	linux-fsdevel <linux-fsdevel@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Christoph Hellwig <hch@...radead.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Robo Bot <apw@...onical.com>, Felix Fietkau <nbd@...nwrt.org>,
	Neil Brown <neilb@...e.de>,
	Jordi Pujol <jordipujolp@...il.com>, ezk@....cs.sunysb.edu,
	"mszeredi@...e.cz" <mszeredi@...e.cz>
Subject: Re: Overlayfs rename bug

On Tue, Jun 24, 2014 at 05:46:14PM +0100, David Howells wrote:

> strace shows:
> 
> 	rename("/mnt/a/foo104", "/mnt/a/foo105") = 0
> 	lstat("/mnt/a/foo104", {st_mode=S_IFREG|0644, st_size=12, ...}) = 0
> 
> which shouldn't happen.

Sorry for the delay.  Following patch fixes it and tests now run fine.

Problem was that copy-up didn't set opaque flag on non-dir.  The reason this has
gone unnoticed is that the dentry on overlayfs was unhashed (to get rid of the
unneeded lower dentry reference) so after a new lookup the opaque flag would be
set correctly.  Rename, however, rehashed the copied up dentry and so old_opaque
and the opaque flag on old would become out-of-sync.

As a followup patch we could also unhash the copied dentry after the rename, but
that's just an optimization.

Thanks for the report and the great test suite!

Miklos


diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 1670dbe..274c857 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -255,9 +255,13 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
 	 * Easiest way to get rid of the lower dentry reference is to
 	 * drop this dentry.  This is neither needed nor possible for
 	 * directories.
+	 *
+	 * Non-directores become opaque when copied up.
 	 */
-	if (!S_ISDIR(stat->mode))
+	if (!S_ISDIR(stat->mode)) {
+		ovl_dentry_set_opaque(dentry, true);
 		d_drop(dentry);
+	}
 out:
 	dput(upper);
 	dput(newdentry);
--
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