Skip to content

Commit 6f36250

Browse files
committed
Merge tag 'erofs-for-6.8-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: - Fix a "BUG: kernel NULL pointer dereference" issue due to inconsistent on-disk indices of compressed inodes against per-sb `available_compr_algs` generated by Syzkaller - Don't use certain unnecessary folio_*() helpers if the folio type (page cache) is known * tag 'erofs-for-6.8-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: Don't use certain unnecessary folio_*() functions erofs: fix inconsistent per-file compression format
2 parents b5f66ba + 2b872b0 commit 6f36250

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

fs/erofs/decompressor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *dsb)
408408
int size, ret = 0;
409409

410410
if (!erofs_sb_has_compr_cfgs(sbi)) {
411-
sbi->available_compr_algs = Z_EROFS_COMPRESSION_LZ4;
411+
sbi->available_compr_algs = 1 << Z_EROFS_COMPRESSION_LZ4;
412412
return z_erofs_load_lz4_config(sb, dsb, NULL, 0);
413413
}
414414

fs/erofs/fscache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
165165
static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
166166
{
167167
int ret;
168-
struct erofs_fscache *ctx = folio_mapping(folio)->host->i_private;
168+
struct erofs_fscache *ctx = folio->mapping->host->i_private;
169169
struct erofs_fscache_request *req;
170170

171-
req = erofs_fscache_req_alloc(folio_mapping(folio),
171+
req = erofs_fscache_req_alloc(folio->mapping,
172172
folio_pos(folio), folio_size(folio));
173173
if (IS_ERR(req)) {
174174
folio_unlock(folio);
@@ -276,7 +276,7 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
276276
struct erofs_fscache_request *req;
277277
int ret;
278278

279-
req = erofs_fscache_req_alloc(folio_mapping(folio),
279+
req = erofs_fscache_req_alloc(folio->mapping,
280280
folio_pos(folio), folio_size(folio));
281281
if (IS_ERR(req)) {
282282
folio_unlock(folio);

fs/erofs/zmap.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static int z_erofs_do_map_blocks(struct inode *inode,
454454
.map = map,
455455
};
456456
int err = 0;
457-
unsigned int lclusterbits, endoff;
457+
unsigned int lclusterbits, endoff, afmt;
458458
unsigned long initial_lcn;
459459
unsigned long long ofs, end;
460460

@@ -543,17 +543,20 @@ static int z_erofs_do_map_blocks(struct inode *inode,
543543
err = -EFSCORRUPTED;
544544
goto unmap_out;
545545
}
546-
if (vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER)
547-
map->m_algorithmformat =
548-
Z_EROFS_COMPRESSION_INTERLACED;
549-
else
550-
map->m_algorithmformat =
551-
Z_EROFS_COMPRESSION_SHIFTED;
552-
} else if (m.headtype == Z_EROFS_LCLUSTER_TYPE_HEAD2) {
553-
map->m_algorithmformat = vi->z_algorithmtype[1];
546+
afmt = vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER ?
547+
Z_EROFS_COMPRESSION_INTERLACED :
548+
Z_EROFS_COMPRESSION_SHIFTED;
554549
} else {
555-
map->m_algorithmformat = vi->z_algorithmtype[0];
550+
afmt = m.headtype == Z_EROFS_LCLUSTER_TYPE_HEAD2 ?
551+
vi->z_algorithmtype[1] : vi->z_algorithmtype[0];
552+
if (!(EROFS_I_SB(inode)->available_compr_algs & (1 << afmt))) {
553+
erofs_err(inode->i_sb, "inconsistent algorithmtype %u for nid %llu",
554+
afmt, vi->nid);
555+
err = -EFSCORRUPTED;
556+
goto unmap_out;
557+
}
556558
}
559+
map->m_algorithmformat = afmt;
557560

558561
if ((flags & EROFS_GET_BLOCKS_FIEMAP) ||
559562
((flags & EROFS_GET_BLOCKS_READMORE) &&

0 commit comments

Comments
 (0)