Skip to contentSkip to conversation

f2fs: forbid U32_MAX project ID

PATCH In review Wang Shilong 2 participants 4 messages Jun 25, 2021 – Jun 28, 2021 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: forbid U32_MAX project ID

From: Wang Shilong <[email protected]>

U32_MAX is reserved for special purpose,
qid_has_mapping() will return false if projid is
4294967295, dqget() will return NULL for it.

So U32_MAX is unsupported Project ID, fix to forbid it.

---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/file.c +2 -0
index ceb575f99048..861edf3c01d5 100644
@@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
 	u32 iflags;
 	int err;
 
+	if (fa->fsx_projid >= U32_MAX)
+		return -EINVAL;
 	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
 		return -EIO;
 	if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))
Signature · 8 lines
2.27.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#1 lore raw
Quoted 18 lines · Wang Shilong

From: Wang Shilong <[email protected]>

U32_MAX is reserved for special purpose,
qid_has_mapping() will return false if projid is
4294967295, dqget() will return NULL for it.

So U32_MAX is unsupported Project ID, fix to forbid it.

---
  fs/f2fs/file.c | 2 ++
  1 file changed, 2 insertions(+)
fs/f2fs/file.c +0 -0
index ceb575f99048..861edf3c01d5 100644

fs/f2fs/file.c int f2fs_fileattr_set(struct user_namespace *mnt_userns, · line 3069

Quoted 4 lines
fs/f2fs/file.c +1 -0
@@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
  	u32 iflags;
  	int err;
 
+	if (fa->fsx_projid >= U32_MAX)

unlikely()? if this is really a corner case.

fs/f2fs/file.c int f2fs_fileattr_set(struct user_namespace *mnt_userns, · line 3073

Quoted 4 lines
fs/f2fs/file.c +1 -0
+		return -EINVAL;
  	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
  		return -EIO;
  	if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))

I prefer to check fsx_projid here to keep line with check order in other f2fs interfaces.

Thoughts, Shilong?

Thanks,

Quoted 1 line

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

#2 lore raw

Hi Chao,

Quoted 27 lines · Chao Yu
Quoted 18 lines · Wang Shilong

From: Wang Shilong <[email protected]>

U32_MAX is reserved for special purpose,
qid_has_mapping() will return false if projid is
4294967295, dqget() will return NULL for it.

So U32_MAX is unsupported Project ID, fix to forbid it.

---
  fs/f2fs/file.c | 2 ++
  1 file changed, 2 insertions(+)
fs/f2fs/file.c +0 -0
index ceb575f99048..861edf3c01d5 100644

fs/f2fs/file.c int f2fs_fileattr_set(struct user_namespace *mnt_userns, · line 3069

Quoted 4 lines
fs/f2fs/file.c +1 -0
@@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
      u32 iflags;
      int err;
 
+     if (fa->fsx_projid >= U32_MAX)

unlikely()? if this is really a corner case.

Quoted 7 lines

fs/f2fs/file.c int f2fs_fileattr_set(struct user_namespace *mnt_userns, · line 3073

Quoted 4 lines
fs/f2fs/file.c +1 -0
+             return -EINVAL;
      if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
              return -EIO;
      if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))

I prefer to check fsx_projid here to keep line with check order in other f2fs interfaces.

Just sent a v2 which tried to fix the problem in the VFS.

Quoted 6 lines

Thoughts, Shilong?

Thanks,

Quoted 1 line

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

maintainer
#3 lore raw
Quoted 35 lines · Wang Shilong

Hi Chao,

Quoted 32 lines · Chao Yu
Quoted 18 lines · Wang Shilong

From: Wang Shilong <[email protected]>

U32_MAX is reserved for special purpose,
qid_has_mapping() will return false if projid is
4294967295, dqget() will return NULL for it.

So U32_MAX is unsupported Project ID, fix to forbid it.

---
   fs/f2fs/file.c | 2 ++
   1 file changed, 2 insertions(+)
fs/f2fs/file.c +0 -0
index ceb575f99048..861edf3c01d5 100644

fs/f2fs/file.c int f2fs_fileattr_set(struct user_namespace *mnt_userns, · line 3069

Quoted 4 lines
fs/f2fs/file.c +1 -0
@@ -3066,6 +3066,8 @@ int f2fs_fileattr_set(struct user_namespace *mnt_userns,
       u32 iflags;
       int err;
 
+     if (fa->fsx_projid >= U32_MAX)

unlikely()? if this is really a corner case.

Quoted 4 lines
fs/f2fs/file.c +1 -0
+             return -EINVAL;
       if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
               return -EIO;
       if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode)))
Quoted 4 lines
Quoted 2 lines

I prefer to check fsx_projid here to keep line with check order in other f2fs interfaces.

Just sent a v2 which tried to fix the problem in the VFS.

Shilong,

Agreed, and better.

Thanks,

Quoted 7 lines
Quoted 7 lines

Thoughts, Shilong?

Thanks,

Quoted 1 line

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