2024-05-09 14:43:11

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] ext4: fix uninitialized ratelimit_state->lock access in __ext4_fill_super()


On Tue, 02 Jan 2024 21:37:30 +0800, Baokun Li wrote:
> In the following concurrency we will access the uninitialized rs->lock:
>
> ext4_fill_super
> ext4_register_sysfs
> // sysfs registered msg_ratelimit_interval_ms
> // Other processes modify rs->interval to
> // non-zero via msg_ratelimit_interval_ms
> ext4_orphan_cleanup
> ext4_msg(sb, KERN_INFO, "Errors on filesystem, "
> __ext4_msg
> ___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state)
> if (!rs->interval) // do nothing if interval is 0
> return 1;
> raw_spin_trylock_irqsave(&rs->lock, flags)
> raw_spin_trylock(lock)
> _raw_spin_trylock
> __raw_spin_trylock
> spin_acquire(&lock->dep_map, 0, 1, _RET_IP_)
> lock_acquire
> __lock_acquire
> register_lock_class
> assign_lock_key
> dump_stack();
> ratelimit_state_init(&sbi->s_msg_ratelimit_state, 5 * HZ, 10);
> raw_spin_lock_init(&rs->lock);
> // init rs->lock here
>
> [...]

Applied, thanks!

[1/1] ext4: fix uninitialized ratelimit_state->lock access in __ext4_fill_super()
commit: b4b4fda34e535756f9e774fb2d09c4537b7dfd1c

Best regards,
--
Theodore Ts'o <[email protected]>