From: Yue Hu <zbestahu@gmail.com>
To: xiang@kernel.org, chao@kernel.org
Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
syzbot+3faecbfd845a895c04cb@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com, zhangwen@coolpad.com,
Yue Hu <huyue2@coolpad.com>
Subject: [PATCH] erofs: fix general protection fault when reading fragment
Date: Fri, 21 Oct 2022 16:31:16 +0800 [thread overview]
Message-ID: <20221021083116.20048-1-zbestahu@gmail.com> (raw)
From: Yue Hu <huyue2@coolpad.com>
As syzbot reported [1], the fragment feature sb flag is not set, so
packed_inode != NULL needs to be checked in z_erofs_read_fragment().
[1] https://lore.kernel.org/all/0000000000002e7a8905eb841ddd@google.com/
Reported-by: syzbot+3faecbfd845a895c04cb@syzkaller.appspotmail.com
Fixes: 08a0c9ef3e7e ("erofs: support on-disk compressed fragments data")
Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
fs/erofs/zdata.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index cce56dde135c..310f6916787a 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -659,6 +659,9 @@ static int z_erofs_read_fragment(struct inode *inode, erofs_off_t pos,
u8 *src, *dst;
unsigned int i, cnt;
+ if (!packed_inode)
+ return -EFAULT;
+
pos += EROFS_I(inode)->z_fragmentoff;
for (i = 0; i < len; i += cnt) {
cnt = min_t(unsigned int, len - i,
--
2.17.1
next reply other threads:[~2022-10-21 8:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-21 8:31 Yue Hu [this message]
2022-10-21 8:47 ` [PATCH] erofs: fix general protection fault when reading fragment Gao Xiang
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=20221021083116.20048-1-zbestahu@gmail.com \
--to=zbestahu@gmail.com \
--cc=chao@kernel.org \
--cc=huyue2@coolpad.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+3faecbfd845a895c04cb@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=xiang@kernel.org \
--cc=zhangwen@coolpad.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