Zhihao Cheng
ac2e498ab2
ubifs: Set/Clear I_LINKABLE under i_lock for whiteout inode
[ Upstream commit a801fcfeef96702fa3f9b22ad56c5eb1989d9221 ]
xfstests-generic/476 reports a warning message as below:
WARNING: CPU: 2 PID: 30347 at fs/inode.c:361 inc_nlink+0x52/0x70
Call Trace:
do_rename+0x502/0xd40 [ubifs]
ubifs_rename+0x8b/0x180 [ubifs]
vfs_rename+0x476/0x1080
do_renameat2+0x67c/0x7b0
__x64_sys_renameat2+0x6e/0x90
do_syscall_64+0x66/0xe0
entry_SYSCALL_64_after_hwframe+0x44/0xae
Following race case can cause this:
rename_whiteout(Thread 1) wb_workfn(Thread 2)
ubifs_rename
do_rename
__writeback_single_inode
spin_lock(&inode->i_lock)
whiteout->i_state |= I_LINKABLE
inode->i_state &= ~dirty;
---- How race happens on i_state:
(tmp = whiteout->i_state | I_LINKABLE)
(tmp = inode->i_state & ~dirty)
(whiteout->i_state = tmp)
(inode->i_state = tmp)
----
spin_unlock(&inode->i_lock)
inc_nlink(whiteout)
WARN_ON(!(inode->i_state & I_LINKABLE)) !!!
Fix to add i_lock to avoid i_state update race condition.
Fixes: 9e0a1fff8db56ea ("ubifs: Implement RENAME_WHITEOUT")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-20 16:05:51 +02:00
..
2021-03-04 11:37:51 +01:00
2019-08-22 17:25:33 +02:00
2020-07-16 12:35:15 -07:00
2019-07-08 19:43:53 +02:00
2019-05-28 10:27:53 -07:00
2020-09-17 22:55:51 +02:00
2019-07-12 12:24:03 -07:00
2021-07-20 16:05:51 +02:00
2020-07-16 12:35:15 -07:00
2019-06-05 17:37:07 +02:00
2020-09-17 23:06:53 +02:00
2020-12-30 11:54:17 +01:00
2020-09-17 22:56:19 +02:00
2021-07-20 16:05:51 +02:00
2019-12-31 10:33:51 -06:00
2020-01-22 14:49:56 -08:00
2019-07-08 19:43:51 +02:00
2020-08-23 17:36:59 -05:00
2020-06-02 10:59:11 -07:00
2020-07-16 12:35:15 -07:00
2019-01-23 23:56:43 -05:00
2020-05-08 15:32:15 +10:00
2018-08-15 00:25:21 +02:00
2020-08-02 22:59:03 +02:00
2020-09-17 22:55:41 +02:00
2019-07-08 19:43:43 +02:00
2021-05-11 14:47:33 +02:00
2020-08-02 22:23:46 +02:00
2019-06-05 17:37:07 +02:00
2019-06-05 17:37:07 +02:00
2021-07-19 09:45:00 +02:00
2019-11-17 22:22:54 +01:00
2020-07-16 12:35:15 -07:00
2020-10-18 09:56:50 -07:00
2019-07-08 19:43:53 +02:00
2021-07-19 09:45:00 +02:00
2021-07-20 16:05:51 +02:00