[4.2.y-ckt stable] Patch "vfs: rename: check backing inode being equal" has been added to the 4.2.y-ckt tree
Kamal Mostafa
kamal at canonical.com
Tue May 24 17:53:00 UTC 2016
This is a note to let you know that I have just added a patch titled
vfs: rename: check backing inode being equal
to the linux-4.2.y-queue branch of the 4.2.y-ckt extended stable tree
which can be found at:
https://git.launchpad.net/~canonical-kernel/linux/+git/linux-stable-ckt/log/?h=linux-4.2.y-queue
This patch is scheduled to be released in version 4.2.8-ckt11.
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 4.2.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
Thanks.
-Kamal
---8<------------------------------------------------------------
>From 43743a4fff0f39c832548ef5bc4984549fb9e9af Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <mszeredi at redhat.com>
Date: Wed, 11 May 2016 01:16:37 +0200
Subject: vfs: rename: check backing inode being equal
commit 9409e22acdfc9153f88d9b1ed2bd2a5b34d2d3ca upstream.
If a file is renamed to a hardlink of itself POSIX specifies that rename(2)
should do nothing and return success.
This condition is checked in vfs_rename(). However it won't detect hard
links on overlayfs where these are given separate inodes on the overlayfs
layer.
Overlayfs itself detects this condition and returns success without doing
anything, but then vfs_rename() will proceed as if this was a successful
rename (detach_mounts(), d_move()).
The correct thing to do is to detect this condition before even calling
into overlayfs. This patch does this by calling vfs_select_inode() to get
the underlying inodes.
Signed-off-by: Miklos Szeredi <mszeredi at redhat.com>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
fs/namei.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/namei.c b/fs/namei.c
index 0402c3c..eda6dfc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4186,7 +4186,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
bool new_is_dir = false;
unsigned max_links = new_dir->i_sb->s_max_links;
- if (source == target)
+ /*
+ * Check source == target.
+ * On overlayfs need to look at underlying inodes.
+ */
+ if (vfs_select_inode(old_dentry, 0) == vfs_select_inode(new_dentry, 0))
return 0;
error = may_delete(old_dir, old_dentry, is_dir);
--
2.7.4
More information about the kernel-team
mailing list