Re: [PATCH] f2fs: fix convert inline inode on readonly mode

From: Chao Yu
Date: Tue Jun 11 2024 - 23:39:41 EST


On 2024/6/12 10:20, Daejun Park wrote:
syzbot reported a bug in f2fs_vm_page_mkwrite() which checks for
f2fs_has_inline_data(inode).
The bug was caused by f2fs_convert_inline_inode() not returning an
error when called on a read-only filesystem, but returning with the
inline attribute as set.
This patch fixes the problem by ensuring that f2fs_convert_inline_inode()
returns -EROFS on readonly.

Fixes: ec2ddf499402 ("f2fs: don't allow any writes on readonly mount")
Reported-by: syzbot+f195123a45ad487ca66c@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=f195123a45ad487ca66c
Signed-off-by: Daejun Park <daejun7.park@xxxxxxxxxxx>

Hi Daejun,

I guess below patch has fixed this issue, so we need to tag the report
as duplicated?

https://lore.kernel.org/linux-f2fs-devel/20240603010745.2246488-1-chao@xxxxxxxxxx/T/#u

Thanks,

---
fs/f2fs/inline.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 7638d0d7b7ee..ae1d8f2d82c9 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -203,10 +203,12 @@ int f2fs_convert_inline_inode(struct inode *inode)
struct page *ipage, *page;
int err = 0;

- if (!f2fs_has_inline_data(inode) ||
- f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb))
+ if (!f2fs_has_inline_data(inode))
return 0;

+ if (unlikely(f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb)))
+ return -EROFS;
+
err = f2fs_dquot_initialize(inode);
if (err)
return err;
--
2.25.1