Bart Van Assche
009bb421b6
workqueue, lockdep: Fix an alloc_workqueue() error path
This patch fixes a use-after-free and a memory leak in an alloc_workqueue()
error path.
Repoted by syzkaller and KASAN:
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:197 [inline]
BUG: KASAN: use-after-free in lockdep_register_key+0x3b9/0x490 kernel/locking/lockdep.c:1023
Read of size 8 at addr ffff888090fc2698 by task syz-executor134/7858
CPU: 1 PID: 7858 Comm: syz-executor134 Not tainted 5.0.0-rc8-next-20190301 #1
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
__asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
__read_once_size include/linux/compiler.h:197 [inline]
lockdep_register_key+0x3b9/0x490 kernel/locking/lockdep.c:1023
wq_init_lockdep kernel/workqueue.c:3444 [inline]
alloc_workqueue+0x427/0xe70 kernel/workqueue.c:4263
ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
misc_open+0x398/0x4c0 drivers/char/misc.c:141
chrdev_open+0x247/0x6b0 fs/char_dev.c:417
do_dentry_open+0x488/0x1160 fs/open.c:771
vfs_open+0xa0/0xd0 fs/open.c:880
do_last fs/namei.c:3416 [inline]
path_openat+0x10e9/0x46e0 fs/namei.c:3533
do_filp_open+0x1a1/0x280 fs/namei.c:3563
do_sys_open+0x3fe/0x5d0 fs/open.c:1063
__do_sys_openat fs/open.c:1090 [inline]
__se_sys_openat fs/open.c:1084 [inline]
__x64_sys_openat+0x9d/0x100 fs/open.c:1084
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Allocated by task 7789:
save_stack+0x45/0xd0 mm/kasan/common.c:75
set_track mm/kasan/common.c:87 [inline]
__kasan_kmalloc mm/kasan/common.c:497 [inline]
__kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:470
kasan_kmalloc+0x9/0x10 mm/kasan/common.c:511
__do_kmalloc mm/slab.c:3726 [inline]
__kmalloc+0x15c/0x740 mm/slab.c:3735
kmalloc include/linux/slab.h:553 [inline]
kzalloc include/linux/slab.h:743 [inline]
alloc_workqueue+0x13c/0xe70 kernel/workqueue.c:4236
ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
misc_open+0x398/0x4c0 drivers/char/misc.c:141
chrdev_open+0x247/0x6b0 fs/char_dev.c:417
do_dentry_open+0x488/0x1160 fs/open.c:771
vfs_open+0xa0/0xd0 fs/open.c:880
do_last fs/namei.c:3416 [inline]
path_openat+0x10e9/0x46e0 fs/namei.c:3533
do_filp_open+0x1a1/0x280 fs/namei.c:3563
do_sys_open+0x3fe/0x5d0 fs/open.c:1063
__do_sys_openat fs/open.c:1090 [inline]
__se_sys_openat fs/open.c:1084 [inline]
__x64_sys_openat+0x9d/0x100 fs/open.c:1084
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 7789:
save_stack+0x45/0xd0 mm/kasan/common.c:75
set_track mm/kasan/common.c:87 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/common.c:459
kasan_slab_free+0xe/0x10 mm/kasan/common.c:467
__cache_free mm/slab.c:3498 [inline]
kfree+0xcf/0x230 mm/slab.c:3821
alloc_workqueue+0xc3e/0xe70 kernel/workqueue.c:4295
ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
misc_open+0x398/0x4c0 drivers/char/misc.c:141
chrdev_open+0x247/0x6b0 fs/char_dev.c:417
do_dentry_open+0x488/0x1160 fs/open.c:771
vfs_open+0xa0/0xd0 fs/open.c:880
do_last fs/namei.c:3416 [inline]
path_openat+0x10e9/0x46e0 fs/namei.c:3533
do_filp_open+0x1a1/0x280 fs/namei.c:3563
do_sys_open+0x3fe/0x5d0 fs/open.c:1063
__do_sys_openat fs/open.c:1090 [inline]
__se_sys_openat fs/open.c:1084 [inline]
__x64_sys_openat+0x9d/0x100 fs/open.c:1084
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff888090fc2580
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 280 bytes inside of
512-byte region [ffff888090fc2580, ffff888090fc2780)
Reported-by: syzbot+17335689e239ce135d8b@syzkaller.appspotmail.com
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Fixes: 669de8bda8
("kernel/workqueue: Use dynamic lockdep keys for workqueues")
Link: https://lkml.kernel.org/r/20190303220046.29448-1-bvanassche@acm.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-03-09 14:15:52 +01:00
..
2019-03-06 07:59:36 -08:00
2019-03-05 08:26:13 -08:00
2018-10-24 20:55:56 -04:00
2018-12-30 08:31:52 +00:00
2019-01-16 09:59:17 -05:00
2019-02-28 08:29:50 +01:00
2018-06-08 18:56:02 +09:00
2019-02-23 10:53:31 +01:00
2018-12-01 12:38:50 -08:00
2019-03-09 14:15:51 +01:00
2018-12-28 12:11:47 -08:00
2019-01-03 18:57:57 -08:00
2019-03-06 07:59:36 -08:00
2019-03-06 08:14:05 -08:00
2019-03-05 14:49:11 -08:00
2019-02-28 08:27:17 +01:00
2018-11-26 18:40:00 -05:00
2018-11-26 18:40:00 -05:00
2018-11-26 18:40:00 -05:00
2018-12-14 12:09:30 -05:00
2018-11-26 18:41:21 -05:00
2018-06-19 10:39:54 -04:00
2018-11-26 18:41:21 -05:00
2018-10-31 08:54:14 -07:00
2019-02-07 00:13:27 +01:00
2019-02-04 08:57:24 +01:00
2018-08-22 10:52:47 -07:00
2018-12-19 13:52:44 -05:00
2018-10-26 16:26:32 -07:00
2018-05-16 07:23:35 +02:00
2018-05-16 07:23:35 +02:00
2019-02-01 15:46:23 -08:00
2018-10-31 08:54:12 -07:00
2019-02-04 08:53:56 +01:00
2018-08-06 12:35:20 +02:00
2019-03-06 07:17:17 -08:00
2019-01-04 13:13:45 -08:00
2018-05-15 23:08:33 -07:00
2019-01-06 09:46:51 +09:00
2019-01-21 17:38:56 -03:00
2019-02-01 20:55:38 +01:00
2018-12-15 17:44:35 +09:00
2019-01-04 13:13:47 -08:00
2018-12-28 12:11:47 -08:00
2018-12-06 14:38:50 +00:00
2018-07-16 12:31:57 -07:00
2019-02-13 08:16:40 +01:00
2019-03-06 08:14:05 -08:00
2019-01-06 09:46:51 +09:00
2018-12-28 12:11:52 -08:00
2018-11-07 14:41:41 +01:00
2018-07-02 11:36:17 +02:00
2019-01-06 09:46:51 +09:00
2018-11-16 14:11:04 +08:00
2019-01-04 13:13:47 -08:00
2018-04-11 10:28:37 -07:00
2018-09-16 16:08:25 +02:00
2018-12-28 12:42:30 -08:00
2018-10-31 08:54:16 -07:00
2019-01-03 18:57:57 -08:00
2018-09-11 16:13:24 +01:00
2019-01-31 14:01:48 +01:00
2018-12-28 12:11:49 -08:00
2019-01-03 18:57:57 -08:00
2019-02-22 00:14:19 +01:00
2019-03-05 14:08:26 -08:00
2019-01-30 19:27:00 +01:00
2018-07-03 09:20:44 +02:00
2019-02-10 21:51:39 +01:00
2018-12-05 19:31:44 -08:00
2018-08-13 11:25:07 -07:00
2019-02-07 00:13:27 +01:00
2019-01-14 10:38:03 +12:00
2019-01-04 13:13:47 -08:00
2019-03-06 08:14:05 -08:00
2018-06-21 12:33:05 +02:00
2019-02-09 08:47:52 -08:00
2018-11-27 09:21:41 -08:00
2018-04-05 21:36:27 -07:00
2019-01-11 18:05:40 -08:00
2018-10-09 16:51:11 +02:00
2018-11-07 23:51:16 -06:00
2018-08-22 10:52:47 -07:00
2018-08-11 02:05:53 -05:00
2018-04-11 10:28:35 -07:00
2018-08-30 12:56:40 +02:00
2018-08-30 12:56:40 +02:00
2019-02-01 15:46:23 -08:00
2019-03-09 14:15:52 +01:00