Skip to content

Commit d2ec799

Browse files
committed
Merge tag 'erofs-for-6.0-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: - Fix return codes in erofs_fscache_{meta_,}read_folio error paths - Fix potential wrong pcluster sizes for later non-4K lclusters - Fix in-memory pcluster use-after-free on UP platforms * tag 'erofs-for-6.0-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: fix pcluster use-after-free on UP platforms erofs: avoid the potentially wrong m_plen for big pcluster erofs: fix error return code in erofs_fscache_{meta_,}read_folio
2 parents 53e99dc + 2f44013 commit d2ec799

File tree

3 files changed

+14
-39
lines changed

3 files changed

+14
-39
lines changed

fs/erofs/fscache.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
222222

223223
rreq = erofs_fscache_alloc_request(folio_mapping(folio),
224224
folio_pos(folio), folio_size(folio));
225-
if (IS_ERR(rreq))
225+
if (IS_ERR(rreq)) {
226+
ret = PTR_ERR(rreq);
226227
goto out;
228+
}
227229

228230
return erofs_fscache_read_folios_async(mdev.m_fscache->cookie,
229231
rreq, mdev.m_pa);
@@ -301,8 +303,10 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
301303

302304
rreq = erofs_fscache_alloc_request(folio_mapping(folio),
303305
folio_pos(folio), folio_size(folio));
304-
if (IS_ERR(rreq))
306+
if (IS_ERR(rreq)) {
307+
ret = PTR_ERR(rreq);
305308
goto out_unlock;
309+
}
306310

307311
pstart = mdev.m_pa + (pos - map.m_la);
308312
return erofs_fscache_read_folios_async(mdev.m_fscache->cookie,

fs/erofs/internal.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ struct erofs_workgroup {
195195
atomic_t refcount;
196196
};
197197

198-
#if defined(CONFIG_SMP)
199198
static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp,
200199
int val)
201200
{
@@ -224,34 +223,6 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
224223
return atomic_cond_read_relaxed(&grp->refcount,
225224
VAL != EROFS_LOCKED_MAGIC);
226225
}
227-
#else
228-
static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp,
229-
int val)
230-
{
231-
preempt_disable();
232-
/* no need to spin on UP platforms, let's just disable preemption. */
233-
if (val != atomic_read(&grp->refcount)) {
234-
preempt_enable();
235-
return false;
236-
}
237-
return true;
238-
}
239-
240-
static inline void erofs_workgroup_unfreeze(struct erofs_workgroup *grp,
241-
int orig_val)
242-
{
243-
preempt_enable();
244-
}
245-
246-
static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
247-
{
248-
int v = atomic_read(&grp->refcount);
249-
250-
/* workgroup is never freezed on uniprocessor systems */
251-
DBG_BUGON(v == EROFS_LOCKED_MAGIC);
252-
return v;
253-
}
254-
#endif /* !CONFIG_SMP */
255226
#endif /* !CONFIG_EROFS_FS_ZIP */
256227

257228
/* we strictly follow PAGE_SIZE and no buffer head yet */

fs/erofs/zmap.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ struct z_erofs_maprecorder {
141141
u8 type, headtype;
142142
u16 clusterofs;
143143
u16 delta[2];
144-
erofs_blk_t pblk, compressedlcs;
144+
erofs_blk_t pblk, compressedblks;
145145
erofs_off_t nextpackoff;
146146
};
147147

@@ -192,7 +192,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m,
192192
DBG_BUGON(1);
193193
return -EFSCORRUPTED;
194194
}
195-
m->compressedlcs = m->delta[0] &
195+
m->compressedblks = m->delta[0] &
196196
~Z_EROFS_VLE_DI_D0_CBLKCNT;
197197
m->delta[0] = 1;
198198
}
@@ -293,7 +293,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
293293
DBG_BUGON(1);
294294
return -EFSCORRUPTED;
295295
}
296-
m->compressedlcs = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
296+
m->compressedblks = lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
297297
m->delta[0] = 1;
298298
return 0;
299299
} else if (i + 1 != (int)vcnt) {
@@ -497,7 +497,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
497497
return 0;
498498
}
499499
lcn = m->lcn + 1;
500-
if (m->compressedlcs)
500+
if (m->compressedblks)
501501
goto out;
502502

503503
err = z_erofs_load_cluster_from_disk(m, lcn, false);
@@ -506,7 +506,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
506506

507507
/*
508508
* If the 1st NONHEAD lcluster has already been handled initially w/o
509-
* valid compressedlcs, which means at least it mustn't be CBLKCNT, or
509+
* valid compressedblks, which means at least it mustn't be CBLKCNT, or
510510
* an internal implemenatation error is detected.
511511
*
512512
* The following code can also handle it properly anyway, but let's
@@ -523,12 +523,12 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
523523
* if the 1st NONHEAD lcluster is actually PLAIN or HEAD type
524524
* rather than CBLKCNT, it's a 1 lcluster-sized pcluster.
525525
*/
526-
m->compressedlcs = 1;
526+
m->compressedblks = 1 << (lclusterbits - LOG_BLOCK_SIZE);
527527
break;
528528
case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
529529
if (m->delta[0] != 1)
530530
goto err_bonus_cblkcnt;
531-
if (m->compressedlcs)
531+
if (m->compressedblks)
532532
break;
533533
fallthrough;
534534
default:
@@ -539,7 +539,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,
539539
return -EFSCORRUPTED;
540540
}
541541
out:
542-
map->m_plen = (u64)m->compressedlcs << lclusterbits;
542+
map->m_plen = (u64)m->compressedblks << LOG_BLOCK_SIZE;
543543
return 0;
544544
err_bonus_cblkcnt:
545545
erofs_err(m->inode->i_sb,

0 commit comments

Comments
 (0)