]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
f2fs: fix to avoid potential panic during recovery
authorChao Yu <chao@kernel.org>
Wed, 24 Jan 2024 14:49:15 +0000 (22:49 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:20:00 +0000 (18:20 -0400)
commit8844b2f8a3f0c428b74672f9726f9950b1a7764c
treeeb58f458596e823efda6430f9f7ffd097c43d3a8
parent5e59e199f3a617a4e3340df642313d8a3664d654
f2fs: fix to avoid potential panic during recovery

[ Upstream commit 21ec68234826b1b54ab980a8df6e33c74cfbee58 ]

During recovery, if FAULT_BLOCK is on, it is possible that
f2fs_reserve_new_block() will return -ENOSPC during recovery,
then it may trigger panic.

Also, if fault injection rate is 1 and only FAULT_BLOCK fault
type is on, it may encounter deadloop in loop of block reservation.

Let's change as below to fix these issues:
- remove bug_on() to avoid panic.
- limit the loop count of block reservation to avoid potential
deadloop.

Fixes: 956fa1ddc132 ("f2fs: fix to check return value of f2fs_reserve_new_block()")
Reported-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/recovery.c