Skip to content

Commit 8bc67e4

Browse files
committed
Merge tag 'erofs-for-7.1-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: - Fix a kernel crash related to unaligned zstd extents - Fix metabuf reference leak in shared xattr initialization * tag 'erofs-for-7.1-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: fix metabuf leak in inode xattr initialization erofs: fix managed cache race for unaligned extents
2 parents df68563 + 79b09c5 commit 8bc67e4

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

fs/erofs/xattr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,11 @@ static int erofs_init_inode_xattrs(struct inode *inode)
8989
vi->xattr_isize - sizeof(struct erofs_xattr_ibody_header)) {
9090
erofs_err(sb, "invalid h_shared_count %u @ nid %llu",
9191
vi->xattr_shared_count, vi->nid);
92-
erofs_put_metabuf(&buf);
9392
ret = -EFSCORRUPTED;
9493
goto out_unlock;
9594
}
9695
vi->xattr_shared_xattrs = kmalloc_objs(uint, vi->xattr_shared_count);
9796
if (!vi->xattr_shared_xattrs) {
98-
erofs_put_metabuf(&buf);
9997
ret = -ENOMEM;
10098
goto out_unlock;
10199
}
@@ -112,12 +110,12 @@ static int erofs_init_inode_xattrs(struct inode *inode)
112110
}
113111
vi->xattr_shared_xattrs[i] = le32_to_cpu(*xattr_id);
114112
}
115-
erofs_put_metabuf(&buf);
116113

117114
/* paired with smp_mb() at the beginning of the function. */
118115
smp_mb();
119116
set_bit(EROFS_I_EA_INITED_BIT, &vi->flags);
120117
out_unlock:
118+
erofs_put_metabuf(&buf);
121119
clear_and_wake_up_bit(EROFS_I_BL_XATTR_BIT, &vi->flags);
122120
return ret;
123121
}

fs/erofs/zdata.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,15 @@ static void z_erofs_fill_bio_vec(struct bio_vec *bvec,
15091509
DBG_BUGON(z_erofs_is_shortlived_page(bvec->bv_page));
15101510

15111511
folio = page_folio(zbv.page);
1512-
/* For preallocated managed folios, add them to page cache here */
1512+
/*
1513+
* Preallocated folios are added to the managed cache here rather than
1514+
* in z_erofs_bind_cache() in order to keep these folios locked in
1515+
* increasing (physical) address order.
1516+
* Clear folio->private before these folios become visible to others in
1517+
* the managed cache to avoid duplicate additions for unaligned extents.
1518+
*/
15131519
if (folio->private == Z_EROFS_PREALLOCATED_FOLIO) {
1520+
folio->private = NULL;
15141521
tocache = true;
15151522
goto out_tocache;
15161523
}
@@ -1546,14 +1553,8 @@ static void z_erofs_fill_bio_vec(struct bio_vec *bvec,
15461553
}
15471554
return;
15481555
}
1549-
/*
1550-
* Already linked with another pcluster, which only appears in
1551-
* crafted images by fuzzers for now. But handle this anyway.
1552-
*/
1553-
tocache = false; /* use temporary short-lived pages */
15541556
} else {
15551557
DBG_BUGON(1); /* referenced managed folios can't be truncated */
1556-
tocache = true;
15571558
}
15581559
folio_unlock(folio);
15591560
folio_put(folio);

0 commit comments

Comments
 (0)