Skip to contentSkip to conversation

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

PATCH Applied Daeho Jeong 4 participants 6 messages Aug 21 – Aug 22 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
#1 lore raw
Quoted 10 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")

Applied without Fixes and stable, since the original patch has not been upstreamed.

Quoted 46 lines
---
 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 · 8 lines
2.55.0.766.g2966f0265a-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#2 lore raw
Quoted 6 lines · On 8/21/26 23:26, Jaegeuk Kim via Linux-f2fs-devel wrote:
Quoted 5 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.

Quoted 8 lines
Quoted 5 lines

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")

Applied without Fixes and stable, since the original patch has not been upstreamed.

Jaegeuk, if we don't plan to merge them, we'd better keep the Fixes and stable line, otherwise, once the two patches be upstreamed, we may missed to backport the fix one due to the missing lines?

Thanks,

Quoted 53 lines
Quoted 47 lines
---
  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 · 8 lines
2.55.0.766.g2966f0265a-goog



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

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

maintainer
#3 lore raw
Quoted 13 lines · Chao Yu
Quoted 12 lines · On 8/21/26 23:26, Jaegeuk Kim via Linux-f2fs-devel wrote:
Quoted 10 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")
Quoted 6 lines
Quoted 2 lines

Applied without Fixes and stable, since the original patch has not been upstreamed.

Jaegeuk, if we don't plan to merge them, we'd better keep the Fixes and stable line, otherwise, once the two patches be upstreamed, we may missed to backport the fix one due to the missing lines?

My concern is the never existing hash in upstream. And, I don't think this will go into any LTS.

Quoted 52 lines

Thanks,

Quoted 48 lines
Quoted 42 lines
---
  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 · 8 lines
2.55.0.766.g2966f0265a-goog



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

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

maintainer
#4 lore raw
Quoted 17 lines · Jaegeuk Kim
Quoted 16 lines · Chao Yu
Quoted 14 lines · On 8/21/26 23:26, Jaegeuk Kim via Linux-f2fs-devel wrote:
Quoted 10 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")

Applied without Fixes and stable, since the original patch has not been upstreamed.

Quoted 6 lines
Quoted 3 lines

Jaegeuk, if we don't plan to merge them, we'd better keep the Fixes and stable line, otherwise, once the two patches be upstreamed, we may missed to backport the fix one due to the missing lines?

My concern is the never existing hash in upstream. And, I don't think this will go into any LTS.

Oh, I see, actually, my concern is developers may potentially miss this fix when backporting related feature.

Thanks,

Quoted 53 lines
Quoted 53 lines

Thanks,

Quoted 48 lines
Quoted 42 lines
---
   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 · 8 lines
2.55.0.766.g2966f0265a-goog



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

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

#5 lore raw
In reply to Daeho Jeong
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 9 lines · On Fri, 21 Aug 2026 07:17:42 -0700 you wrote:

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.

[...]

Here is the summary with links:
- [f2fs-dev] f2fs: fix error handling on device alias check in rename and unlink

    https://git.kernel.org/jaegeuk/f2fs/c/27d0e27c096d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html