* Re: [PATCH] ocfs2: replace BUG_ON with error return in
[not found] <20260417101227.2490949-1-tristmd@gmail.com>
@ 2026-04-17 10:12 ` syzbot
0 siblings, 0 replies; only message in thread
From: syzbot @ 2026-04-17 10:12 UTC (permalink / raw)
To: tristmd; +Cc: tristmd, linux-kernel, syzkaller-bugs
> From: Tristan Madani <tristan@talencesecurity.com>
>
> #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
This crash does not have a reproducer. I cannot test it.
>
> __ocfs2_page_mkwrite
>
> __ocfs2_page_mkwrite() calls ocfs2_write_end_nolock() and panics the
> kernel via BUG_ON if the return value is not equal to the requested
> length:
>
> err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
> BUG_ON(err != len);
>
> When the filesystem encounters I/O errors or on-disk corruption
> (e.g. from a crafted image), ocfs2_write_end_nolock() can return
> a negative error code or a short write count. This crashes the
> kernel instead of returning an error to userspace.
>
> Replace the BUG_ON with a proper error return path that converts
> the failure to a VM_FAULT_SIGBUS, which gracefully reports the
> fault to the application.
>
> Reported-by: syzbot+ea5aff81e35d189b9335@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ea5aff81e35d189b9335
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
> fs/ocfs2/mmap.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
> index XXXXXXX..XXXXXXX 100644
> --- a/fs/ocfs2/mmap.c
> +++ b/fs/ocfs2/mmap.c
> @@ -105,7 +105,12 @@ static vm_fault_t __ocfs2_page_mkwrite(struct vm_fault *vmf,
> goto out;
> }
> err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
> - BUG_ON(err != len);
> + if (unlikely(err != len)) {
> + if (err >= 0)
> + err = -EIO;
> + ret = vmf_error(err);
> + goto out;
> + }
> ret = VM_FAULT_LOCKED;
> out:
> return ret;
> --
> 2.43.0
^ permalink raw reply [flat|nested] only message in thread