Zhihao Cheng
2536906dbc
ubifs: Set/Clear I_LINKABLE under i_lock for whiteout inode
[ Upstream commit a801fcfeef ]
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: 9e0a1fff8d ("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>
2023-05-16 11:27:34 +09:00
..
2023-05-16 09:45:39 +09:00
2023-05-15 14:09:05 +09:00
2023-05-16 09:05:59 +09:00
2023-05-15 16:47:08 +09:00
2023-05-15 16:08:48 +09:00
2016-10-15 12:09:13 -07:00
2023-05-15 09:57:32 +09:00
2023-05-16 11:23:18 +09:00
2023-05-16 09:45:46 +09:00
2023-05-16 11:27:16 +09:00
2023-05-16 11:05:17 +09:00
2023-05-15 14:09:19 +09:00
2023-05-16 11:24:54 +09:00
2023-05-15 09:23:12 +09:00
2023-05-16 09:44:26 +09:00
2023-05-15 12:38:42 +09:00
2023-05-15 12:05:59 +09:00
2023-05-16 11:23:25 +09:00
2023-05-16 11:05:36 +09:00
2023-05-16 09:50:21 +09:00
2020-02-04 13:48:58 +09:00
2023-05-15 09:51:17 +09:00
2023-05-15 16:42:45 +09:00
2023-05-16 08:48:08 +09:00
2023-05-16 11:22:40 +09:00
2023-05-16 11:04:00 +09:00
2023-05-15 17:33:02 +09:00
2023-05-15 10:31:45 +09:00
2023-05-16 11:25:51 +09:00
2023-05-16 11:14:40 +09:00
2023-05-15 15:18:29 +09:00
2023-05-15 17:14:59 +09:00
2016-10-10 20:16:43 -07:00
2016-10-10 20:16:43 -07:00
2023-05-16 11:11:10 +09:00
2023-05-16 10:37:43 +09:00
2023-05-16 08:57:16 +09:00
2023-05-16 10:54:39 +09:00
2023-05-16 11:26:38 +09:00
2023-05-15 15:09:25 +09:00
2023-05-16 09:57:34 +09:00
2018-03-02 13:27:29 -08:00
2023-05-16 08:47:27 +09:00
2023-05-15 11:49:44 +09:00
2023-05-16 11:27:33 +09:00
2023-05-16 09:58:02 +09:00
2023-05-16 10:26:47 +09:00
2023-05-16 11:16:24 +09:00
2023-05-15 11:16:44 +09:00
2023-05-16 11:22:29 +09:00
2023-05-16 11:23:54 +09:00
2016-10-10 20:16:43 -07:00
2023-05-16 11:27:15 +09:00
2023-05-16 10:35:54 +09:00
2023-05-16 11:14:30 +09:00
2023-05-15 16:32:06 +09:00
2023-05-16 10:00:31 +09:00
2016-10-10 20:16:43 -07:00
2023-05-16 11:25:12 +09:00
2023-05-16 08:54:39 +09:00
2020-12-17 17:32:09 +09:00
2023-05-16 11:04:20 +09:00
2023-05-16 10:40:14 +09:00
2023-05-15 10:31:02 +09:00
2023-05-16 11:27:34 +09:00
2023-05-16 11:25:15 +09:00
2023-05-16 08:48:37 +09:00
2023-05-16 10:39:53 +09:00
2023-05-15 10:36:26 +09:00
2017-01-31 10:47:22 -08:00
2017-01-09 08:32:24 +01:00
2023-05-15 17:30:19 +09:00
2023-05-15 13:55:59 +09:00
2023-05-16 10:47:44 +09:00
2023-05-15 14:54:58 +09:00
2023-05-16 09:16:10 +09:00
2023-05-16 09:45:07 +09:00
2023-05-15 17:27:22 +09:00
2018-02-25 11:05:55 +01:00
2023-05-15 16:30:53 +09:00
2017-07-05 16:18:14 +02:00
2018-02-28 10:18:33 +01:00
2023-05-15 12:07:04 +09:00
2023-05-16 10:51:34 +09:00
2023-05-15 11:50:41 +09:00
2023-05-16 09:23:53 +09:00
2023-05-16 10:33:11 +09:00
2018-01-31 12:55:52 +01:00
2023-05-15 17:28:32 +09:00
2017-01-31 15:46:26 -08:00
2023-05-16 11:24:17 +09:00
2023-05-15 17:11:10 +09:00
2017-09-20 09:59:51 +02:00
2017-09-20 08:19:59 +02:00
2017-09-26 00:32:37 -07:00
2023-05-16 09:49:21 +09:00
2023-05-15 16:30:25 +09:00
2017-09-26 00:32:37 -07:00
2018-02-22 15:43:48 +01:00
2017-07-21 07:42:22 +02:00
2018-12-17 17:21:59 +08:00
2023-05-15 17:02:00 +09:00
2023-05-15 17:23:05 +09:00
2018-02-17 13:21:15 +01:00
2023-05-15 17:09:26 +09:00
2023-05-15 13:40:35 +09:00
2023-05-15 17:24:29 +09:00
2017-03-15 02:21:16 +00:00
2017-01-26 08:24:37 +01:00
2017-01-31 10:47:20 -08:00
2023-05-15 13:41:13 +09:00
2023-05-15 16:21:37 +09:00
2023-05-16 10:48:22 +09:00
2016-10-07 18:46:30 -07:00
2023-05-15 13:40:35 +09:00
2017-06-14 15:06:01 +02:00
2023-05-16 09:49:08 +09:00
2017-03-14 13:16:06 -07:00
2017-05-08 07:47:54 +02:00
2023-05-15 14:21:05 +09:00
2017-01-31 10:47:21 -08:00
2023-05-16 08:45:19 +09:00