linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: fix convert inline inode on readonly mode
       [not found] <CGME20240612022012epcms2p77300b5130d18b0397c9fc2877704949d@epcms2p7>
@ 2024-06-12  2:20 ` Daejun Park
  2024-06-12  3:39   ` Chao Yu
       [not found]   ` <CGME20240612022012epcms2p77300b5130d18b0397c9fc2877704949d@epcms2p2>
  0 siblings, 2 replies; 3+ messages in thread
From: Daejun Park @ 2024-06-12  2:20 UTC (permalink / raw)
  To: jaegeuk@kernel.org, chao@kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
  Cc: Nayeon Kim, Siwoo Jung, Seokhwan Kim, Dongjin Kim

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@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f195123a45ad487ca66c
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
---
 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



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix convert inline inode on readonly mode
  2024-06-12  2:20 ` [f2fs-dev] [PATCH] f2fs: fix convert inline inode on readonly mode Daejun Park
@ 2024-06-12  3:39   ` Chao Yu
       [not found]   ` <CGME20240612022012epcms2p77300b5130d18b0397c9fc2877704949d@epcms2p2>
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2024-06-12  3:39 UTC (permalink / raw)
  To: daejun7.park, jaegeuk@kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
  Cc: Nayeon Kim, Siwoo Jung, Seokhwan Kim, Dongjin Kim

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@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=f195123a45ad487ca66c
> Signed-off-by: Daejun Park <daejun7.park@samsung.com>

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@kernel.org/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
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] (2) [PATCH] f2fs: fix convert inline inode on readonly mode
       [not found]   ` <CGME20240612022012epcms2p77300b5130d18b0397c9fc2877704949d@epcms2p2>
@ 2024-06-12  4:50     ` Daejun Park
  0 siblings, 0 replies; 3+ messages in thread
From: Daejun Park @ 2024-06-12  4:50 UTC (permalink / raw)
  To: Chao Yu, jaegeuk@kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
  Cc: Nayeon Kim, Siwoo Jung, Seokhwan Kim, Dongjin Kim

> 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@syzkaller.appspotmail.com
> > Closes: https://protect2.fireeye.com/v1/url?k=4fe36b34-10785251-4fe2e07b-000babff32e3-e4235a49bbe14a93&q=1&e=b7eda9c4-8db2-474e-801d-f3eb85d38066&u=https%3A%2F%2Fsyzkaller.appspot.com%2Fbug%3Fextid%3Df195123a45ad487ca66c
> > Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> 
> 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@kernel.org/T/#u
> 
> Thanks,

Hi Chao,

I didn't check that patch, please simply ignore it, thank you :)

Thanks,
Daejun

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


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-12  4:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20240612022012epcms2p77300b5130d18b0397c9fc2877704949d@epcms2p7>
2024-06-12  2:20 ` [f2fs-dev] [PATCH] f2fs: fix convert inline inode on readonly mode Daejun Park
2024-06-12  3:39   ` Chao Yu
     [not found]   ` <CGME20240612022012epcms2p77300b5130d18b0397c9fc2877704949d@epcms2p2>
2024-06-12  4:50     ` [f2fs-dev] (2) " Daejun Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).