mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Edward Adam Davis <eadavis@qq.com>,
	syzbot+81092778aac03460d6b7@syzkaller.appspotmail.com
Cc: jlbec@evilplan.org, linux-kernel@vger.kernel.org,
	mark@fasheh.com, ocfs2-devel@lists.linux.dev,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] ocfs2: pass u64 to ocfs2_truncate_inline maybe overflow
Date: Thu, 10 Oct 2024 20:21:59 +0800	[thread overview]
Message-ID: <4195446e-2d2b-442c-a1ad-b1498d243a70@linux.alibaba.com> (raw)
In-Reply-To: <tencent_B22CA96C8896C0E9FEEFD2CCAC795A6E500A@qq.com>



On 10/9/24 11:05 PM, Edward Adam Davis wrote:
> Syzbot reported a kernel BUG in ocfs2_truncate_inline.
> There are two reasons for this: first, the parameter value passed is greater
> than UINT_MAX, second, the start and end parameters of ocfs2_truncate_inline
> are "unsigned int".
> 
> So, we need to add a sanity check for offset and len in ocfs2_fallocate, if
> they are greater than UINT_MAX return -EFBIG.

fallocate should accept loff_t (aka long long) offset and len.
I guess the reported bug is caused by a crafted image, which set
overflow offset and len in case of inline data (with flag
OCFS2_INLINE_DATA_FL set).
So IMO, the right place to add a sanity check is right before
ocfs2_truncate_inline() in ocfs2_remove_inode_range().

Thanks,
Joseph

> 
> Reported-and-tested-by: syzbot+81092778aac03460d6b7@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=81092778aac03460d6b7
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
>  fs/ocfs2/file.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index ad131a2fc58e..ed26ec8ac6b6 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -2117,6 +2117,9 @@ static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
>  			return ret;
>  	}
>  
> +	if (offset > UINT_MAX || offset + len > UINT_MAX)
> +		return -EFBIG;
> +
>  	if (mode & FALLOC_FL_PUNCH_HOLE)
>  		cmd = OCFS2_IOC_UNRESVSP64;
>  


  reply	other threads:[~2024-10-10 12:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09  6:18 [syzbot] [ocfs2?] kernel BUG in ocfs2_truncate_inline syzbot
2024-10-09  9:00 ` Edward Adam Davis
2024-10-09 14:11   ` [syzbot] " syzbot
2024-10-09 15:05 ` [PATCH] ocfs2: pass u64 to ocfs2_truncate_inline maybe overflow Edward Adam Davis
2024-10-10 12:21   ` Joseph Qi [this message]
2024-10-10 14:31     ` [PATCH V2] " Edward Adam Davis
2024-10-11  1:07       ` Su Yue
2024-10-11  2:01         ` Joseph Qi
2024-10-16  2:08           ` Joseph Qi
2024-10-16  3:22             ` [PATCH V3] " Edward Adam Davis
2024-10-16  9:49               ` Joseph Qi
2024-10-16 11:43                 ` [PATCH V4] " Edward Adam Davis
2024-10-16 11:47                   ` Joseph Qi
2024-10-16 11:54                     ` Joseph Qi
2024-10-10 14:32 ` [ocfs2?] kernel BUG in ocfs2_truncate_inline Edward Adam Davis
2024-10-10 16:31   ` [syzbot] " syzbot
2024-10-16  3:29 ` Edward Adam Davis
2024-10-16  4:59   ` [syzbot] " syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4195446e-2d2b-442c-a1ad-b1498d243a70@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=eadavis@qq.com \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=syzbot+81092778aac03460d6b7@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®