Zhihao Cheng
971bc532b2
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:21:14 +02:00
..
2020-11-10 10:23:58 +01:00
2021-07-20 16:21:14 +02:00
2020-02-14 16:31:00 -05:00
2016-10-02 22:55:02 +02:00
2021-01-17 13:57:54 +01:00
2018-09-09 20:01:24 +02:00
2015-11-07 11:35:08 +01:00
2016-01-10 12:33:30 +01:00
2018-09-09 20:01:24 +02:00
2016-10-02 22:55:02 +02:00
2016-03-20 21:36:05 +01:00
2016-03-20 21:36:05 +01:00
2015-11-06 23:26:48 +01:00
2015-11-06 23:26:52 +01:00
2018-12-29 13:40:16 +01:00
2016-05-20 17:58:30 -07:00
2018-10-13 09:18:58 +02:00
2016-08-23 23:02:40 +02:00
2017-01-26 08:24:40 +01:00
2016-10-02 22:55:02 +02:00
2018-02-17 13:21:14 +01:00