Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:36020 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750793AbeELBZ6 (ORCPT ); Fri, 11 May 2018 21:25:58 -0400 Date: Sat, 12 May 2018 02:25:57 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Miklos Szeredi Subject: [RFC][PATCH] ovl_create_index(): vfs_mkdir() might succeed leaving dentry negative unhashed Message-ID: <20180512012557.GJ30522@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: [same story as with the previous two patches] Signed-off-by: Al Viro --- diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 8bede0742619..cdd8f8816d2a 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -373,6 +373,22 @@ static int ovl_create_index(struct dentry *dentry, struct dentry *origin, if (err) goto out; + if (unlikely(d_unhashed(temp))) { + struct dentry *d = lookup_one_len(temp->d_name.name, + temp->d_parent, + temp->d_name.len); + if (IS_ERR(d)) { + err = PTR_ERR(d); + goto out; + } + dput(temp); + temp = d; + if (d_is_negative(temp)) { + err = -EIO; + goto out; + } + } + err = ovl_set_upper_fh(upper, temp); if (err) goto out_cleanup;