Qian Cai
e06aeb9f3d
jbd2: fix data races at struct journal_head
...
[ Upstream commit 6c5d911249290f41f7b50b43344a7520605b1acb ]
journal_head::b_transaction and journal_head::b_next_transaction could
be accessed concurrently as noticed by KCSAN,
LTP: starting fsync04
/dev/zero: Can't open blockdev
EXT4-fs (loop0): mounting ext3 file system using the ext4 subsystem
EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null)
==================================================================
BUG: KCSAN: data-race in __jbd2_journal_refile_buffer [jbd2] / jbd2_write_access_granted [jbd2]
write to 0xffff99f9b1bd0e30 of 8 bytes by task 25721 on cpu 70:
__jbd2_journal_refile_buffer+0xdd/0x210 [jbd2]
__jbd2_journal_refile_buffer at fs/jbd2/transaction.c:2569
jbd2_journal_commit_transaction+0x2d15/0x3f20 [jbd2]
(inlined by) jbd2_journal_commit_transaction at fs/jbd2/commit.c:1034
kjournald2+0x13b/0x450 [jbd2]
kthread+0x1cd/0x1f0
ret_from_fork+0x27/0x50
read to 0xffff99f9b1bd0e30 of 8 bytes by task 25724 on cpu 68:
jbd2_write_access_granted+0x1b2/0x250 [jbd2]
jbd2_write_access_granted at fs/jbd2/transaction.c:1155
jbd2_journal_get_write_access+0x2c/0x60 [jbd2]
__ext4_journal_get_write_access+0x50/0x90 [ext4]
ext4_mb_mark_diskspace_used+0x158/0x620 [ext4]
ext4_mb_new_blocks+0x54f/0xca0 [ext4]
ext4_ind_map_blocks+0xc79/0x1b40 [ext4]
ext4_map_blocks+0x3b4/0x950 [ext4]
_ext4_get_block+0xfc/0x270 [ext4]
ext4_get_block+0x3b/0x50 [ext4]
__block_write_begin_int+0x22e/0xae0
__block_write_begin+0x39/0x50
ext4_write_begin+0x388/0xb50 [ext4]
generic_perform_write+0x15d/0x290
ext4_buffered_write_iter+0x11f/0x210 [ext4]
ext4_file_write_iter+0xce/0x9e0 [ext4]
new_sync_write+0x29c/0x3b0
__vfs_write+0x92/0xa0
vfs_write+0x103/0x260
ksys_write+0x9d/0x130
__x64_sys_write+0x4c/0x60
do_syscall_64+0x91/0xb05
entry_SYSCALL_64_after_hwframe+0x49/0xbe
5 locks held by fsync04/25724:
#0 : ffff99f9911093f8 (sb_writers#13){.+.+}, at: vfs_write+0x21c/0x260
#1 : ffff99f9db4c0348 (&sb->s_type->i_mutex_key#15){+.+.}, at: ext4_buffered_write_iter+0x65/0x210 [ext4]
#2 : ffff99f5e7dfcf58 (jbd2_handle){++++}, at: start_this_handle+0x1c1/0x9d0 [jbd2]
#3 : ffff99f9db4c0168 (&ei->i_data_sem){++++}, at: ext4_map_blocks+0x176/0x950 [ext4]
#4 : ffffffff99086b40 (rcu_read_lock){....}, at: jbd2_write_access_granted+0x4e/0x250 [jbd2]
irq event stamp: 1407125
hardirqs last enabled at (1407125): [<ffffffff980da9b7>] __find_get_block+0x107/0x790
hardirqs last disabled at (1407124): [<ffffffff980da8f9>] __find_get_block+0x49/0x790
softirqs last enabled at (1405528): [<ffffffff98a0034c>] __do_softirq+0x34c/0x57c
softirqs last disabled at (1405521): [<ffffffff97cc67a2>] irq_exit+0xa2/0xc0
Reported by Kernel Concurrency Sanitizer on:
CPU: 68 PID: 25724 Comm: fsync04 Tainted: G L 5.6.0-rc2-next-20200221+ #7
Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019
The plain reads are outside of jh->b_state_lock critical section which result
in data races. Fix them by adding pairs of READ|WRITE_ONCE().
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Qian Cai <cai@lca.pw>
Link: https://lore.kernel.org/r/20200222043111.2227-1-cai@lca.pw
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-03-20 09:07:58 +01:00
..
2019-10-17 13:42:10 -07:00
2019-08-06 18:29:35 +02:00
2018-05-30 07:50:16 +02:00
2020-01-29 10:24:34 +01:00
2019-12-21 10:40:46 +01:00
2016-10-15 12:09:13 -07:00
2018-12-01 09:44:19 +01:00
2020-02-28 15:42:53 +01:00
2018-12-17 09:38:34 +01:00
2019-11-28 18:28:34 +01:00
2020-03-20 09:07:44 +01:00
2019-08-06 18:29:38 +02:00
2019-11-12 19:15:51 +01:00
2018-11-13 11:17:03 -08:00
2019-07-21 09:05:59 +02:00
2019-05-08 07:19:10 +02:00
2019-03-23 13:19:47 +01:00
2019-12-21 10:41:21 +01:00
2020-03-11 07:53:06 +01:00
2016-10-10 20:16:43 -07:00
2018-11-27 16:09:38 +01:00
2020-01-29 10:24:03 +01:00
2020-02-14 16:31:05 -05:00
2020-03-11 07:53:05 +01:00
2020-01-23 08:19:37 +01:00
2020-03-11 07:53:11 +01:00
2018-12-17 09:38:34 +01:00
2019-12-21 10:41:30 +01:00
2020-03-20 09:07:44 +01:00
2019-11-28 18:28:50 +01:00
2019-11-28 18:28:49 +01:00
2016-10-10 20:16:43 -07:00
2016-10-10 20:16:43 -07:00
2019-05-31 06:48:12 -07:00
2017-11-30 08:39:04 +00:00
2020-03-20 09:07:58 +01:00
2019-05-08 07:19:09 +02:00
2020-01-29 10:24:19 +01:00
2019-11-25 09:52:23 +01:00
2018-11-13 11:17:02 -08:00
2016-10-10 20:16:43 -07:00
2016-10-10 20:16:43 -07:00
2019-03-13 14:04:52 -07:00
2020-03-20 09:07:37 +01:00
2018-02-03 17:05:38 +01:00
2020-02-14 16:31:06 -05:00
2018-05-30 07:50:16 +02:00
2019-02-06 17:33:30 +01:00
2016-10-30 13:09:42 -04:00
2020-02-28 15:42:41 +01:00
2016-10-10 20:16:43 -07:00
2016-09-27 21:06:21 -04:00
2020-02-28 15:42:43 +01:00
2019-10-05 12:30:34 +02:00
2019-11-25 09:53:44 +01:00
2020-01-12 11:24:20 +01:00
2020-01-04 13:40:50 +01:00
2016-10-10 20:16:43 -07:00
2020-02-28 15:42:41 +01:00
2017-06-17 06:41:56 +02:00
2018-09-05 09:20:03 +02:00
2018-09-05 09:20:10 +02:00
2018-12-17 09:38:32 +01:00
2016-09-27 21:06:21 -04:00
2020-02-14 16:31:00 -05:00
2020-02-28 15:42:30 +01:00
2019-05-25 18:26:56 +02:00
2020-01-29 10:24:00 +01:00
2018-12-21 14:11:31 +01:00
2016-10-10 20:16:43 -07:00
2017-01-09 08:32:24 +01:00
2018-09-26 08:36:37 +02:00
2019-07-10 09:55:38 +02:00
2018-06-26 08:08:09 +08:00
2019-11-06 12:18:04 +01:00
2019-01-23 08:10:56 +01:00
2019-04-05 22:29:08 +02:00
2020-01-14 20:04:25 +01:00
2018-02-25 11:05:55 +01:00
2020-01-12 11:24:17 +01:00
2016-09-27 21:20:53 -04:00
2017-07-05 14:40:26 +02:00
2018-02-28 10:18:33 +01:00
2019-03-27 14:13:04 +09:00
2019-03-05 17:57:05 +01:00
2019-03-13 14:04:58 -07:00
2019-02-12 19:44:59 +01:00
2019-08-04 09:33:45 +02:00
2018-01-31 12:55:52 +01:00
2019-04-05 22:29:07 +02:00
2019-11-12 19:16:11 +01:00
2019-06-22 08:17:24 +02:00
2017-09-20 08:20:01 +02:00
2017-09-20 08:19:59 +02:00
2016-10-07 18:46:29 -07:00
2019-10-17 13:42:45 -07:00
2020-01-12 11:24:13 +01:00
2018-02-22 15:43:48 +01:00
2017-07-21 07:42:22 +02:00
2017-10-18 09:35:39 +02:00
2020-03-11 07:53:07 +01:00
2018-11-21 09:26:02 +01:00
2018-02-17 13:21:15 +01:00
2020-03-20 09:07:44 +01:00
2019-06-11 12:22:45 +02:00
2017-07-21 07:42:22 +02:00
2017-03-15 10:02:43 +08:00
2017-01-26 08:24:37 +01:00
2019-06-11 12:22:49 +02:00
2020-01-04 13:41:06 +01:00
2016-10-11 15:06:30 -07:00
2016-10-07 18:46:30 -07:00
2019-06-11 12:22:45 +02:00
2017-06-14 15:06:01 +02:00
2019-02-06 17:33:29 +01:00
2017-05-08 07:47:54 +02:00
2019-09-06 10:19:37 +02:00
2016-10-08 11:06:08 -04:00
2018-10-10 08:53:22 +02:00