Skip to contentSkip to conversation

f2fs: fix error handling on device alias check in rename and unlink

PATCH In review Daeho Jeong 3 participants 3 messages Aug 21 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix error handling on device alias check in rename and unlink

From: Daeho Jeong <[email protected]>

In f2fs_rename() and f2fs_unlink(), directly returning -EPERM when encountering a device aliasing file bypasses the cleanup path.

Fix this by setting err to -EPERM and jumping to the proper cleanup labels (out_dir and out) instead of returning immediately.

Fixes a737e409a3d6 ("f2fs: support dynamic reserve/release for device aliasing")
---
 fs/f2fs/namei.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
fs/f2fs/namei.c +8 -4
index 784f636244e1..b9b15c5d28de 100644
@@ -571,8 +571,10 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
 
 	trace_f2fs_unlink_enter(dir, dentry);
 
-	if (IS_DEVICE_ALIASING(inode))
-		return -EPERM;
+	if (IS_DEVICE_ALIASING(inode)) {
+		err = -EPERM;
+		goto out;
+	}
 
 	if (unlikely(f2fs_cp_error(sbi))) {
 		err = -EIO;
@@ -1025,8 +1027,10 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	}
 
 	if (new_inode) {
-		if (IS_DEVICE_ALIASING(new_inode))
-			return -EPERM;
+		if (IS_DEVICE_ALIASING(new_inode)) {
+			err = -EPERM;
+			goto out_dir;
+		}
 
 		err = -ENOTEMPTY;
 		if (old_is_dir && !f2fs_empty_dir(new_inode))
Signature · 1 line
2.55.0.766.g2966f0265a-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

In f2fs_rename() and f2fs_unlink(), directly returning -EPERM when encountering a device aliasing file bypasses the cleanup path.

Fix this by setting err to -EPERM and jumping to the proper cleanup labels (out_dir and out) instead of returning immediately.

Fixes a737e409a3d6 ("f2fs: support dynamic reserve/release for device aliasing")

Thanks,

#2 lore raw
In reply to Daeho Jeong

Le 21/08/2026 à 03:18, Daeho Jeong a écrit :

Quoted 11 lines

From: Daeho Jeong <[email protected]>

In f2fs_rename() and f2fs_unlink(), directly returning -EPERM when encountering a device aliasing file bypasses the cleanup path.

Fix this by setting err to -EPERM and jumping to the proper cleanup labels (out_dir and out) instead of returning immediately.

Fixes a737e409a3d6 ("f2fs: support dynamic reserve/release for device aliasing")

Hi,
if possible, a

would be appreciated.

CJ> ---

Quoted 23 lines
  fs/f2fs/namei.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)
fs/f2fs/namei.c +4 -2
index 784f636244e1..b9b15c5d28de 100644
@@ -571,8 +571,10 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
 
  	trace_f2fs_unlink_enter(dir, dentry);
 
-	if (IS_DEVICE_ALIASING(inode))
-		return -EPERM;
+	if (IS_DEVICE_ALIASING(inode)) {
+		err = -EPERM;
+		goto out;
+	}
 
  	if (unlikely(f2fs_cp_error(sbi))) {
  		err = -EIO;
@@ -1025,8 +1027,10 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
  	}
 

fs/f2fs/namei.c static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, · line 1036

Quoted 10 lines
fs/f2fs/namei.c +4 -2
  	if (new_inode) {
-		if (IS_DEVICE_ALIASING(new_inode))
-			return -EPERM;
+		if (IS_DEVICE_ALIASING(new_inode)) {
+			err = -EPERM;
+			goto out_dir;
+		}
 
  		err = -ENOTEMPTY;
  		if (old_is_dir && !f2fs_empty_dir(new_inode))

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel