Skip to contentSkip to conversation

f2fs: compress: fix to disallow enabling compress on non-empty file

PATCH In review Chao Yu 3 participants 9 messages Sep 18, 2020 – Sep 25, 2020 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs: compress: fix to disallow enabling compress on non-empty file

Compressed inode and normal inode has different layout, so we should disallow enabling compress on non-empty file to avoid race condition during inode .i_addr array parsing and updating.

---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/file.c +2 -0
index 58e464cc15f0..139fdfc1dc55 100644
@@ -1821,6 +1821,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 		if (iflags & F2FS_COMPR_FL) {
 			if (!f2fs_may_compress(inode))
 				return -EINVAL;
+			if (inode->i_size)
+				return -EINVAL;
 
 			set_compress_context(inode);
 		}
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 14 lines · Chao Yu

Compressed inode and normal inode has different layout, so we should disallow enabling compress on non-empty file to avoid race condition during inode .i_addr array parsing and updating.

---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/file.c +0 -0
index 58e464cc15f0..139fdfc1dc55 100644

fs/f2fs/file.c static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) · line 1824

Quoted 4 lines
fs/f2fs/file.c +1 -0
@@ -1821,6 +1821,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 		if (iflags & F2FS_COMPR_FL) {
 			if (!f2fs_may_compress(inode))
 				return -EINVAL;
+			if (inode->i_size)

Changed like this.

+ if (S_ISREG(inode->i_mode) && inode->i_size)

Quoted 6 lines
fs/f2fs/file.c +1 -0
+				return -EINVAL;
 
 			set_compress_context(inode);
 		}
Signature · 1 line
2.26.2
author
#2 lore raw
Quoted 22 lines · Jaegeuk Kim
Quoted 14 lines · Chao Yu

Compressed inode and normal inode has different layout, so we should disallow enabling compress on non-empty file to avoid race condition during inode .i_addr array parsing and updating.

---
  fs/f2fs/file.c | 2 ++
  1 file changed, 2 insertions(+)
fs/f2fs/file.c +0 -0
index 58e464cc15f0..139fdfc1dc55 100644

fs/f2fs/file.c static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) · line 1824

Quoted 4 lines
fs/f2fs/file.c +1 -0
@@ -1821,6 +1821,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
  		if (iflags & F2FS_COMPR_FL) {
  			if (!f2fs_may_compress(inode))
  				return -EINVAL;
+			if (inode->i_size)

Changed like this.

Quoted 1 line

+ if (S_ISREG(inode->i_mode) && inode->i_size)

My bad, thanks for fixing this. :)

Thanks,

Quoted 10 lines
Quoted 8 lines
fs/f2fs/file.c +1 -0
+				return -EINVAL;
 
  			set_compress_context(inode);
  		}
Signature · 1 line
2.26.2

.

maintainer
#5 lore raw
Quoted 7 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

Jaegeuk,

I noticed that in dev branch there are several patches which have not been sent to mailing list, could you please send them out?

Chao, which patches?

Jaegeuk, they are

f2fs: point man pages for some f2fs utils
f2fs: fix slab leak of rpages pointer

Thanks,

Quoted 10 lines
Quoted 3 lines

Thanks,

_______________________________________________
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
#6 lore raw
Quoted 4 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Quoted 2 lines · Chao Yu

Jaegeuk,

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I noticed that in dev branch there are several patches which have not been sent to mailing list, could you please send them out?

Chao, which patches?

Jaegeuk, they are

f2fs: point man pages for some f2fs utils

Ah, just sent.

Quoted 1 line

f2fs: fix slab leak of rpages pointer

I did before?

Quoted 13 lines

Thanks,

Quoted 10 lines
Quoted 3 lines

Thanks,

_______________________________________________
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
#7 lore raw
Quoted 12 lines · Jaegeuk Kim
Quoted 11 lines · Chao Yu
Quoted 7 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

Jaegeuk,

I noticed that in dev branch there are several patches which have not been sent to mailing list, could you please send them out?

Chao, which patches?

Jaegeuk, they are

Quoted 7 lines
Quoted 1 line

f2fs: point man pages for some f2fs utils

Ah, just sent.

Quoted 1 line

f2fs: fix slab leak of rpages pointer

I did before?

I missed to add f2fs mailing list. Resent them.

Quoted 16 lines
Quoted 14 lines

Thanks,

Quoted 10 lines
Quoted 3 lines

Thanks,

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

Quoted 4 lines

_______________________________________________
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
#8 lore raw
Quoted 15 lines · Jaegeuk Kim
Quoted 14 lines · Jaegeuk Kim
Quoted 12 lines · Chao Yu
Quoted 7 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

Jaegeuk,

I noticed that in dev branch there are several patches which have not been sent to mailing list, could you please send them out?

Chao, which patches?

Jaegeuk, they are

f2fs: point man pages for some f2fs utils

Quoted 7 lines
Quoted 5 lines

Ah, just sent.

Quoted 1 line

f2fs: fix slab leak of rpages pointer

I did before?

I missed to add f2fs mailing list. Resent them.

Jaegeuk, thanks, :)

Thanks,

Quoted 17 lines
Quoted 17 lines
Quoted 15 lines

Thanks,

Quoted 10 lines
Quoted 3 lines

Thanks,

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

Quoted 4 lines
Quoted 4 lines

_______________________________________________
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