mirror of
https://github.com/torvalds/linux.git
synced 2024-10-22 21:20:52 +00:00
Changes since last update:
- Make sure only regular inodes can be used for file-backed mounts; - Two minor codebase cleanups. -----BEGIN PGP SIGNATURE----- iQJFBAABCgAvFiEEQ0A6bDUS9Y+83NPFUXZn5Zlu5qoFAmcNHqARHHhpYW5nQGtl cm5lbC5vcmcACgkQUXZn5Zlu5qo1XA/+MFbobJ4bWxJQKnouLlCiFQ5C1xEFbVn2 HasHLfrMIcdz/n/S3Ib4Ayi+9W0zM2Ekq9EG+fuOBqjZP17+EOj3e7OPtVVPNwx0 u2GbD9zNCliZg9PigCfPO+6oImt6l/Mytmx+7bELqbMywAy7JNCNesJuyycsTcja o1I3dNNUZdppilohXPIENTRLjBlOuGBaZdUXDih0LqB+Pb0jgXTP6JfD88h1MLFw xBbhqQ1A/GgyESfsMpZFn2xvFIocLBCIAdAehi9M1AiEwCTjGkTZ66WW3H6Es/Zp vcC9KjHJoGGCXxZf8mnoQHQo/WqQuNUPc2BVf9iExzCo0nwRArcTbAu5Bskqg0LF c+a7FrrxhODz8ioxOOiMUqG4b3/qGkzlk6w5a/t7IRrmFtmcXmPWZ14aI8qpy7o/ CW3iPUoF/zEsmmFvOgJtHwy3g+bC8KhDvz3fqFIDSSMjSKjqb4cPYSe/L5MyhwED wmLgp1uYjEyR0uuqqUp93FEYIbHuO5HpPRT5crLczRIoYn7bXRhjNWLCTmzlLqrj yDAQsrngK99BQ7g0FTQ/OV9si/HRRGsusZmCkeCb6KnRNIvml4X9/WXKc1ioOFk/ 3MSaxlQlTXzCCctjVCDNn9GfD/yR1cXu2sUpGSEnP1ssLG4ARyXGVfoeSw7gJ4xn C5lm9SOmkzU= =0gFG -----END PGP SIGNATURE----- Merge tag 'erofs-for-6.12-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs Pull erofs fixes from Gao Xiang: "The main one fixes a syzbot issue due to the invalid inode type out of file-backed mounts. The others are minor cleanups without actual logic changes. Summary: - Make sure only regular inodes can be used for file-backed mounts - Two minor codebase cleanups" * tag 'erofs-for-6.12-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: get rid of kaddr in `struct z_erofs_maprecorder` erofs: get rid of z_erofs_try_to_claim_pcluster() erofs: ensure regular inodes for file-backed mounts
This commit is contained in:
commit
63fa605041
|
@ -191,10 +191,14 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
|
|||
if (IS_ERR(file))
|
||||
return PTR_ERR(file);
|
||||
|
||||
dif->file = file;
|
||||
if (!erofs_is_fileio_mode(sbi))
|
||||
if (!erofs_is_fileio_mode(sbi)) {
|
||||
dif->dax_dev = fs_dax_get_by_bdev(file_bdev(file),
|
||||
&dif->dax_part_off, NULL, NULL);
|
||||
} else if (!S_ISREG(file_inode(file)->i_mode)) {
|
||||
fput(file);
|
||||
return -EINVAL;
|
||||
}
|
||||
dif->file = file;
|
||||
}
|
||||
|
||||
dif->blocks = le32_to_cpu(dis->blocks);
|
||||
|
@ -714,7 +718,10 @@ static int erofs_fc_get_tree(struct fs_context *fc)
|
|||
if (IS_ERR(sbi->fdev))
|
||||
return PTR_ERR(sbi->fdev);
|
||||
|
||||
return get_tree_nodev(fc, erofs_fc_fill_super);
|
||||
if (S_ISREG(file_inode(sbi->fdev)->i_mode) &&
|
||||
sbi->fdev->f_mapping->a_ops->read_folio)
|
||||
return get_tree_nodev(fc, erofs_fc_fill_super);
|
||||
fput(sbi->fdev);
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
|
|
|
@ -710,24 +710,6 @@ static int z_erofs_attach_page(struct z_erofs_decompress_frontend *fe,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void z_erofs_try_to_claim_pcluster(struct z_erofs_decompress_frontend *f)
|
||||
{
|
||||
struct z_erofs_pcluster *pcl = f->pcl;
|
||||
z_erofs_next_pcluster_t *owned_head = &f->owned_head;
|
||||
|
||||
/* type 1, nil pcluster (this pcluster doesn't belong to any chain.) */
|
||||
if (cmpxchg(&pcl->next, Z_EROFS_PCLUSTER_NIL,
|
||||
*owned_head) == Z_EROFS_PCLUSTER_NIL) {
|
||||
*owned_head = &pcl->next;
|
||||
/* so we can attach this pcluster to our submission chain. */
|
||||
f->mode = Z_EROFS_PCLUSTER_FOLLOWED;
|
||||
return;
|
||||
}
|
||||
|
||||
/* type 2, it belongs to an ongoing chain */
|
||||
f->mode = Z_EROFS_PCLUSTER_INFLIGHT;
|
||||
}
|
||||
|
||||
static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)
|
||||
{
|
||||
struct erofs_map_blocks *map = &fe->map;
|
||||
|
@ -803,7 +785,6 @@ static int z_erofs_pcluster_begin(struct z_erofs_decompress_frontend *fe)
|
|||
int ret;
|
||||
|
||||
DBG_BUGON(fe->pcl);
|
||||
|
||||
/* must be Z_EROFS_PCLUSTER_TAIL or pointed to previous pcluster */
|
||||
DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_NIL);
|
||||
|
||||
|
@ -823,7 +804,15 @@ static int z_erofs_pcluster_begin(struct z_erofs_decompress_frontend *fe)
|
|||
|
||||
if (ret == -EEXIST) {
|
||||
mutex_lock(&fe->pcl->lock);
|
||||
z_erofs_try_to_claim_pcluster(fe);
|
||||
/* check if this pcluster hasn't been linked into any chain. */
|
||||
if (cmpxchg(&fe->pcl->next, Z_EROFS_PCLUSTER_NIL,
|
||||
fe->owned_head) == Z_EROFS_PCLUSTER_NIL) {
|
||||
/* .. so it can be attached to our submission chain */
|
||||
fe->owned_head = &fe->pcl->next;
|
||||
fe->mode = Z_EROFS_PCLUSTER_FOLLOWED;
|
||||
} else { /* otherwise, it belongs to an inflight chain */
|
||||
fe->mode = Z_EROFS_PCLUSTER_INFLIGHT;
|
||||
}
|
||||
} else if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
struct z_erofs_maprecorder {
|
||||
struct inode *inode;
|
||||
struct erofs_map_blocks *map;
|
||||
void *kaddr;
|
||||
|
||||
unsigned long lcn;
|
||||
/* compression extent information gathered */
|
||||
u8 type, headtype;
|
||||
|
@ -33,14 +31,11 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
|
|||
struct z_erofs_lcluster_index *di;
|
||||
unsigned int advise;
|
||||
|
||||
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
|
||||
pos, EROFS_KMAP);
|
||||
if (IS_ERR(m->kaddr))
|
||||
return PTR_ERR(m->kaddr);
|
||||
|
||||
m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);
|
||||
di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, EROFS_KMAP);
|
||||
if (IS_ERR(di))
|
||||
return PTR_ERR(di);
|
||||
m->lcn = lcn;
|
||||
di = m->kaddr;
|
||||
m->nextpackoff = pos + sizeof(struct z_erofs_lcluster_index);
|
||||
|
||||
advise = le16_to_cpu(di->di_advise);
|
||||
m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK;
|
||||
|
@ -53,8 +48,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
|
|||
DBG_BUGON(1);
|
||||
return -EFSCORRUPTED;
|
||||
}
|
||||
m->compressedblks = m->delta[0] &
|
||||
~Z_EROFS_LI_D0_CBLKCNT;
|
||||
m->compressedblks = m->delta[0] & ~Z_EROFS_LI_D0_CBLKCNT;
|
||||
m->delta[0] = 1;
|
||||
}
|
||||
m->delta[1] = le16_to_cpu(di->di_u.delta[1]);
|
||||
|
@ -110,9 +104,9 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
|
|||
struct erofs_inode *const vi = EROFS_I(m->inode);
|
||||
const unsigned int lclusterbits = vi->z_logical_clusterbits;
|
||||
unsigned int vcnt, lo, lobits, encodebits, nblk, bytes;
|
||||
int i;
|
||||
u8 *in, type;
|
||||
bool big_pcluster;
|
||||
u8 *in, type;
|
||||
int i;
|
||||
|
||||
if (1 << amortizedshift == 4 && lclusterbits <= 14)
|
||||
vcnt = 2;
|
||||
|
@ -121,6 +115,10 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
|
|||
else
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, EROFS_KMAP);
|
||||
if (IS_ERR(in))
|
||||
return PTR_ERR(in);
|
||||
|
||||
/* it doesn't equal to round_up(..) */
|
||||
m->nextpackoff = round_down(pos, vcnt << amortizedshift) +
|
||||
(vcnt << amortizedshift);
|
||||
|
@ -128,9 +126,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
|
|||
lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1U);
|
||||
encodebits = ((vcnt << amortizedshift) - sizeof(__le32)) * 8 / vcnt;
|
||||
bytes = pos & ((vcnt << amortizedshift) - 1);
|
||||
|
||||
in = m->kaddr - bytes;
|
||||
|
||||
in -= bytes;
|
||||
i = bytes >> amortizedshift;
|
||||
|
||||
lo = decode_compactedbits(lobits, in, encodebits * i, &type);
|
||||
|
@ -255,10 +251,6 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m,
|
|||
amortizedshift = 2;
|
||||
out:
|
||||
pos += lcn * (1 << amortizedshift);
|
||||
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
|
||||
pos, EROFS_KMAP);
|
||||
if (IS_ERR(m->kaddr))
|
||||
return PTR_ERR(m->kaddr);
|
||||
return unpack_compacted_index(m, amortizedshift, pos, lookahead);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user