Patch "shmem: Fix shmem_rename2()" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    shmem: Fix shmem_rename2()

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     shmem-fix-shmem_rename2.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d9c833db15b3cb0096afb9a2b7caa8f06c966ca5
Author: Chuck Lever <chuck.lever@xxxxxxxxxx>
Date:   Mon Apr 15 11:20:56 2024 -0400

    shmem: Fix shmem_rename2()
    
    [ Upstream commit ad191eb6d6942bb835a0b20b647f7c53c1d99ca4 ]
    
    When renaming onto an existing directory entry, user space expects
    the replacement entry to have the same directory offset as the
    original one.
    
    Link: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15966
    Fixes: a2e459555c5f ("shmem: stable directory offsets")
    Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240415152057.4605-4-cel@xxxxxxxxxx
    Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/libfs.c b/fs/libfs.c
index bb6731fa63059..ef700d39f0f35 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -365,6 +365,9 @@ int simple_offset_empty(struct dentry *dentry)
  *
  * Caller provides appropriate serialization.
  *
+ * User space expects the directory offset value of the replaced
+ * (new) directory entry to be unchanged after a rename.
+ *
  * Returns zero on success, a negative errno value on failure.
  */
 int simple_offset_rename(struct inode *old_dir, struct dentry *old_dentry,
@@ -372,8 +375,14 @@ int simple_offset_rename(struct inode *old_dir, struct dentry *old_dentry,
 {
 	struct offset_ctx *old_ctx = old_dir->i_op->get_offset_ctx(old_dir);
 	struct offset_ctx *new_ctx = new_dir->i_op->get_offset_ctx(new_dir);
+	long new_offset = dentry2offset(new_dentry);
 
 	simple_offset_remove(old_ctx, old_dentry);
+
+	if (new_offset) {
+		offset_set(new_dentry, 0);
+		return simple_offset_replace(new_ctx, old_dentry, new_offset);
+	}
 	return simple_offset_add(new_ctx, old_dentry);
 }
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux