CVE-2024-47689
Severity CVSS v4.0:
Pending analysis
Type:
CWE-362
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
Publication date:
21/10/2024
Last modified:
23/10/2024
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
f2fs: fix to don&#39;t set SB_RDONLY in f2fs_handle_critical_error()<br />
<br />
syzbot reports a f2fs bug as below:<br />
<br />
------------[ cut here ]------------<br />
WARNING: CPU: 1 PID: 58 at kernel/rcu/sync.c:177 rcu_sync_dtor+0xcd/0x180 kernel/rcu/sync.c:177<br />
CPU: 1 UID: 0 PID: 58 Comm: kworker/1:2 Not tainted 6.10.0-syzkaller-12562-g1722389b0d86 #0<br />
Workqueue: events destroy_super_work<br />
RIP: 0010:rcu_sync_dtor+0xcd/0x180 kernel/rcu/sync.c:177<br />
Call Trace:<br />
percpu_free_rwsem+0x41/0x80 kernel/locking/percpu-rwsem.c:42<br />
destroy_super_work+0xec/0x130 fs/super.c:282<br />
process_one_work kernel/workqueue.c:3231 [inline]<br />
process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3312<br />
worker_thread+0x86d/0xd40 kernel/workqueue.c:3390<br />
kthread+0x2f0/0x390 kernel/kthread.c:389<br />
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147<br />
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244<br />
<br />
As Christian Brauner pointed out [1]: the root cause is f2fs sets<br />
SB_RDONLY flag in internal function, rather than setting the flag<br />
covered w/ sb->s_umount semaphore via remount procedure, then below<br />
race condition causes this bug:<br />
<br />
- freeze_super()<br />
- sb_wait_write(sb, SB_FREEZE_WRITE)<br />
- sb_wait_write(sb, SB_FREEZE_PAGEFAULT)<br />
- sb_wait_write(sb, SB_FREEZE_FS)<br />
- f2fs_handle_critical_error<br />
- sb->s_flags |= SB_RDONLY<br />
- thaw_super<br />
- thaw_super_locked<br />
- sb_rdonly() is true, so it skips<br />
sb_freeze_unlock(sb, SB_FREEZE_FS)<br />
- deactivate_locked_super<br />
<br />
Since f2fs has almost the same logic as ext4 [2] when handling critical<br />
error in filesystem if it mounts w/ errors=remount-ro option:<br />
- set CP_ERROR_FLAG flag which indicates filesystem is stopped<br />
- record errors to superblock<br />
- set SB_RDONLY falg<br />
Once we set CP_ERROR_FLAG flag, all writable interfaces can detect the<br />
flag and stop any further updates on filesystem. So, it is safe to not<br />
set SB_RDONLY flag, let&#39;s remove the logic and keep in line w/ ext4 [3].<br />
<br />
[1] https://lore.kernel.org/all/20240729-himbeeren-funknetz-96e62f9c7aee@brauner<br />
[2] https://lore.kernel.org/all/20240729132721.hxih6ehigadqf7wx@quack3<br />
[3] https://lore.kernel.org/linux-ext4/20240805201241.27286-1-jack@suse.cz
Impact
Base Score 3.x
5.30
Severity 3.x
MEDIUM
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.4.4 (including) | 6.5 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.5 (including) | 6.6.54 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.7 (including) | 6.10.13 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.11 (including) | 6.11.2 (excluding) |
To consult the complete list of CPE names with products and versions, see this page



