Dae R. Jeong
70eb256f8c
md: fix a warning caused by a race between concurrent md_ioctl()s
...
commit c731b84b51bf7fe83448bea8f56a6d55006b0615 upstream.
Syzkaller reports a warning as belows.
WARNING: CPU: 0 PID: 9647 at drivers/md/md.c:7169
...
Call Trace:
...
RIP: 0010:md_ioctl+0x4017/0x5980 drivers/md/md.c:7169
RSP: 0018:ffff888096027950 EFLAGS: 00010293
RAX: ffff88809322c380 RBX: 0000000000000932 RCX: ffffffff84e266f2
RDX: 0000000000000000 RSI: ffffffff84e299f7 RDI: 0000000000000007
RBP: ffff888096027bc0 R08: ffff88809322c380 R09: ffffed101341a482
R10: ffff888096027940 R11: ffff88809a0d240f R12: 0000000000000932
R13: ffff8880a2c14100 R14: ffff88809a0d2268 R15: ffff88809a0d2408
__blkdev_driver_ioctl block/ioctl.c:304 [inline]
blkdev_ioctl+0xece/0x1c10 block/ioctl.c:606
block_ioctl+0xee/0x130 fs/block_dev.c:1930
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:509 [inline]
do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:696
ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
__do_sys_ioctl fs/ioctl.c:720 [inline]
__se_sys_ioctl fs/ioctl.c:718 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
This is caused by a race between two concurrenct md_ioctl()s closing
the array.
CPU1 (md_ioctl()) CPU2 (md_ioctl())
------ ------
set_bit(MD_CLOSING, &mddev->flags);
did_set_md_closing = true;
WARN_ON_ONCE(test_bit(MD_CLOSING,
&mddev->flags));
if(did_set_md_closing)
clear_bit(MD_CLOSING, &mddev->flags);
Fix the warning by returning immediately if the MD_CLOSING bit is set
in &mddev->flags which indicates that the array is being closed.
Fixes: 065e519e71b2 ("md: MD_CLOSING needs to be cleared after called md_set_readonly or do_md_stop")
Reported-by: syzbot+1e46a0864c1a6e9bd3d8@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dae R. Jeong <dae.r.jeong@kaist.ac.kr>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-26 16:02:45 +01:00
..
2020-11-30 09:20:32 +01:00
2020-11-27 10:44:59 -08:00
2020-10-17 15:05:30 -06:00
2020-10-30 14:51:01 -07:00
2020-11-18 16:42:07 -08:00
2020-11-02 18:14:07 +01:00
2020-10-01 16:23:50 +03:00
2020-12-09 10:31:37 +01:00
2020-10-30 16:57:41 -05:00
2020-11-19 11:05:48 +02:00
2020-11-15 10:15:17 -08:00
2020-12-07 13:58:49 -08:00
2020-10-25 14:51:49 -07:00
2020-11-01 17:17:31 +00:00
2020-11-23 12:55:01 +01:00
2020-11-16 13:24:32 +01:00
2020-10-28 11:41:15 -06:00
2020-11-22 10:48:22 -08:00
2020-09-29 17:50:10 +09:00
2020-11-20 10:23:49 -08:00
2020-10-15 14:43:29 -07:00
2020-10-12 13:26:49 -07:00
2020-09-30 00:40:06 +09:00
2020-09-25 06:20:48 +02:00
2020-12-09 23:00:22 +01:00
2020-12-01 18:46:24 +01:00
2020-12-09 09:41:49 +01:00
2020-12-11 09:54:30 +10:00
2020-12-26 16:02:43 +01:00
2020-11-16 15:02:33 -08:00
2020-11-13 06:46:20 -08:00
2020-12-26 16:02:42 +01:00
2020-12-05 14:52:35 +01:00
2020-10-17 11:01:01 -07:00
2020-10-13 12:12:44 -07:00
2020-12-03 10:00:23 +01:00
2020-11-14 17:33:47 +00:00
2020-12-09 15:51:35 -04:00
2020-12-12 09:41:33 -08:00
2020-11-20 16:01:35 +02:00
2020-12-09 09:59:14 -08:00
2020-11-25 00:56:28 +01:00
2020-10-07 12:02:58 +02:00
2020-10-16 09:28:45 -06:00
2020-10-16 12:21:15 -07:00
2020-10-24 10:39:22 -07:00
2020-12-26 16:02:45 +01:00
2020-12-26 16:02:45 +01:00
2020-10-24 10:39:22 -07:00
2020-09-28 12:17:36 +02:00
2020-10-26 16:57:18 -04:00
2020-10-14 15:56:58 -07:00
2020-12-11 23:23:30 +01:00
2020-12-04 15:35:54 +01:00
2020-12-11 20:10:02 +01:00
2020-12-10 14:29:30 -08:00
2020-11-24 15:00:53 -08:00
2020-10-25 11:12:31 -07:00
2020-10-13 18:38:28 -07:00
2020-11-14 09:57:55 +01:00
2020-09-27 14:25:48 +02:00
2020-11-11 17:10:16 -06:00
2020-10-27 13:21:03 +05:30
2020-10-06 07:07:03 +02:00
2020-11-04 13:55:30 -06:00
2020-09-25 06:12:15 +02:00
2020-10-01 22:30:07 +01:00
2020-11-16 13:21:28 +05:30
2020-12-09 09:08:18 +01:00
2020-11-26 15:49:16 +01:00
2020-10-27 19:23:04 +01:00
2020-10-24 10:33:08 -07:00
2020-11-10 10:02:31 -08:00
2020-11-25 17:24:49 -08:00
2020-12-03 09:57:37 -08:00
2020-10-16 11:11:22 -07:00
2020-09-25 19:05:31 +02:00
2020-11-18 17:59:24 +00:00
2020-10-22 12:56:33 -07:00
2020-10-24 10:39:22 -07:00
2020-10-22 12:58:21 -07:00
2020-10-21 11:22:08 -07:00
2020-11-27 14:38:02 -08:00
2020-12-26 16:02:43 +01:00
2020-09-25 14:41:51 +02:00
2020-12-26 16:02:38 +01:00
2020-10-01 22:59:55 +02:00
2020-11-25 12:54:05 +00:00
2020-11-25 10:35:44 -08:00
2020-11-20 16:24:28 -08:00
2020-11-27 14:48:03 -08:00
2020-11-12 12:30:29 +01:00
2020-11-19 17:44:10 +03:00
2020-12-26 16:02:43 +01:00
2020-11-09 18:54:30 +01:00
2020-12-26 16:02:40 +01:00
2020-12-02 04:09:56 -05:00
2020-11-03 11:07:40 -07:00
2020-12-02 04:36:40 -05:00
2020-11-23 15:29:03 -08:00
2020-11-09 18:20:36 +01:00
2020-10-23 11:00:57 -07:00
2020-10-05 14:49:24 +02:00
2020-10-24 10:33:08 -07:00
2020-12-09 10:31:41 +01:00
2020-12-02 04:09:56 -05:00