Skip to content

Commit 10c5f10

Browse files
committed
Merge tag 'erofs-for-5.18-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fixes from Gao Xiang: "One patch to fix a use-after-free race related to the on-stack z_erofs_decompressqueue, which happens very rarely but needs to be fixed properly soon. The other patch fixes some sysfs Sphinx warnings" * tag 'erofs-for-5.18-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: Documentation/ABI: sysfs-fs-erofs: Fix Sphinx errors erofs: fix use-after-free of on-stack io[]
2 parents 906f904 + 8b1ac84 commit 10c5f10

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

Documentation/ABI/testing/sysfs-fs-erofs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ Description: Shows all enabled kernel features.
99
What: /sys/fs/erofs/<disk>/sync_decompress
1010
Date: November 2021
1111
Contact: "Huang Jianan" <huangjianan@oppo.com>
12-
Description: Control strategy of sync decompression
12+
Description: Control strategy of sync decompression:
13+
1314
- 0 (default, auto): enable for readpage, and enable for
14-
readahead on atomic contexts only,
15+
readahead on atomic contexts only.
1516
- 1 (force on): enable for readpage and readahead.
1617
- 2 (force off): disable for all situations.

fs/erofs/zdata.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,12 +1066,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,
10661066

10671067
/* wake up the caller thread for sync decompression */
10681068
if (sync) {
1069-
unsigned long flags;
1070-
1071-
spin_lock_irqsave(&io->u.wait.lock, flags);
10721069
if (!atomic_add_return(bios, &io->pending_bios))
1073-
wake_up_locked(&io->u.wait);
1074-
spin_unlock_irqrestore(&io->u.wait.lock, flags);
1070+
complete(&io->u.done);
1071+
10751072
return;
10761073
}
10771074

@@ -1217,7 +1214,7 @@ jobqueue_init(struct super_block *sb,
12171214
} else {
12181215
fg_out:
12191216
q = fgq;
1220-
init_waitqueue_head(&fgq->u.wait);
1217+
init_completion(&fgq->u.done);
12211218
atomic_set(&fgq->pending_bios, 0);
12221219
}
12231220
q->sb = sb;
@@ -1419,8 +1416,7 @@ static void z_erofs_runqueue(struct super_block *sb,
14191416
return;
14201417

14211418
/* wait until all bios are completed */
1422-
io_wait_event(io[JQ_SUBMIT].u.wait,
1423-
!atomic_read(&io[JQ_SUBMIT].pending_bios));
1419+
wait_for_completion_io(&io[JQ_SUBMIT].u.done);
14241420

14251421
/* handle synchronous decompress queue in the caller context */
14261422
z_erofs_decompress_queue(&io[JQ_SUBMIT], pagepool);

fs/erofs/zdata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct z_erofs_decompressqueue {
9797
z_erofs_next_pcluster_t head;
9898

9999
union {
100-
wait_queue_head_t wait;
100+
struct completion done;
101101
struct work_struct work;
102102
} u;
103103
};

0 commit comments

Comments
 (0)