Skip to contentSkip to conversation

erofs: fix general protection fault when reading fragment

PATCH In review Yue Hu 3 participants 3 messages Oct 21, 2022 – Nov 8, 2022 EROFS file system

lore
Share & tools
lore

Yue Hu

author reviewer
#0 lore raw

PATCH v2 1/1 erofs: fix general protection fault when reading fragment

From: Yue Hu <[email protected]>

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/[email protected]/

Reported-by [email protected]
Fixes 08a0c9ef3e7e ("erofs: support on-disk compressed fragments data")

---
v2: fix return value to -EFSCURRUPTED (Xiang)

 fs/erofs/zdata.c | 3 +++
 1 file changed, 3 insertions(+)
fs/erofs/zdata.c +3 -0
index cce56dde135c..55c13cd6934b 100644
@@ -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 -EFSCORRUPTED;
+
 	pos += EROFS_I(inode)->z_fragmentoff;
 	for (i = 0; i < len; i += cnt) {
 		cnt = min_t(unsigned int, len - i,
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Yue Hu

From: Yue Hu <[email protected]>

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/[email protected]/

Reported-by [email protected]
Fixes 08a0c9ef3e7e ("erofs: support on-disk compressed fragments data")

Thanks,
Gao Xiang

Quoted 22 lines

---
v2: fix return value to -EFSCURRUPTED (Xiang)

 fs/erofs/zdata.c | 3 +++
 1 file changed, 3 insertions(+)
fs/erofs/zdata.c +3 -0
index cce56dde135c..55c13cd6934b 100644
@@ -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 -EFSCORRUPTED;
+
 	pos += EROFS_I(inode)->z_fragmentoff;
 	for (i = 0; i < len; i += cnt) {
 		cnt = min_t(unsigned int, len - i,
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Yue Hu
Quoted 10 lines · Yue Hu

From: Yue Hu <[email protected]>

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/[email protected]/

Reported-by [email protected]
Fixes 08a0c9ef3e7e ("erofs: support on-disk compressed fragments data")

Thanks,