Tetsuo Handa
0de023ab7d
mm,vmscan: Make unregister_shrinker() no-op if register_shrinker() failed.
...
commit bb422a738f6566f7439cd347d54e321e4fe92a9f upstream.
Syzbot caught an oops at unregister_shrinker() because combination of
commit 1d3d4437eae1bb29 ("vmscan: per-node deferred work") and fault
injection made register_shrinker() fail and the caller of
register_shrinker() did not check for failure.
----------
[ 554.881422] FAULT_INJECTION: forcing a failure.
[ 554.881422] name failslab, interval 1, probability 0, space 0, times 0
[ 554.881438] CPU: 1 PID: 13231 Comm: syz-executor1 Not tainted 4.14.0-rc8+ #82
[ 554.881443] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
[ 554.881445] Call Trace:
[ 554.881459] dump_stack+0x194/0x257
[ 554.881474] ? arch_local_irq_restore+0x53/0x53
[ 554.881486] ? find_held_lock+0x35/0x1d0
[ 554.881507] should_fail+0x8c0/0xa40
[ 554.881522] ? fault_create_debugfs_attr+0x1f0/0x1f0
[ 554.881537] ? check_noncircular+0x20/0x20
[ 554.881546] ? find_next_zero_bit+0x2c/0x40
[ 554.881560] ? ida_get_new_above+0x421/0x9d0
[ 554.881577] ? find_held_lock+0x35/0x1d0
[ 554.881594] ? __lock_is_held+0xb6/0x140
[ 554.881628] ? check_same_owner+0x320/0x320
[ 554.881634] ? lock_downgrade+0x990/0x990
[ 554.881649] ? find_held_lock+0x35/0x1d0
[ 554.881672] should_failslab+0xec/0x120
[ 554.881684] __kmalloc+0x63/0x760
[ 554.881692] ? lock_downgrade+0x990/0x990
[ 554.881712] ? register_shrinker+0x10e/0x2d0
[ 554.881721] ? trace_event_raw_event_module_request+0x320/0x320
[ 554.881737] register_shrinker+0x10e/0x2d0
[ 554.881747] ? prepare_kswapd_sleep+0x1f0/0x1f0
[ 554.881755] ? _down_write_nest_lock+0x120/0x120
[ 554.881765] ? memcpy+0x45/0x50
[ 554.881785] sget_userns+0xbcd/0xe20
(...snipped...)
[ 554.898693] kasan: CONFIG_KASAN_INLINE enabled
[ 554.898724] kasan: GPF could be caused by NULL-ptr deref or user memory access
[ 554.898732] general protection fault: 0000 [#1 ] SMP KASAN
[ 554.898737] Dumping ftrace buffer:
[ 554.898741] (ftrace buffer empty)
[ 554.898743] Modules linked in:
[ 554.898752] CPU: 1 PID: 13231 Comm: syz-executor1 Not tainted 4.14.0-rc8+ #82
[ 554.898755] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
[ 554.898760] task: ffff8801d1dbe5c0 task.stack: ffff8801c9e38000
[ 554.898772] RIP: 0010:__list_del_entry_valid+0x7e/0x150
[ 554.898775] RSP: 0018:ffff8801c9e3f108 EFLAGS: 00010246
[ 554.898780] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 554.898784] RDX: 0000000000000000 RSI: ffff8801c53c6f98 RDI: ffff8801c53c6fa0
[ 554.898788] RBP: ffff8801c9e3f120 R08: 1ffff100393c7d55 R09: 0000000000000004
[ 554.898791] R10: ffff8801c9e3ef70 R11: 0000000000000000 R12: 0000000000000000
[ 554.898795] R13: dffffc0000000000 R14: 1ffff100393c7e45 R15: ffff8801c53c6f98
[ 554.898800] FS: 0000000000000000(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
[ 554.898804] CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
[ 554.898807] CR2: 00000000dbc23000 CR3: 00000001c7269000 CR4: 00000000001406e0
[ 554.898813] DR0: 0000000020000000 DR1: 0000000020000000 DR2: 0000000000000000
[ 554.898816] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600
[ 554.898818] Call Trace:
[ 554.898828] unregister_shrinker+0x79/0x300
[ 554.898837] ? perf_trace_mm_vmscan_writepage+0x750/0x750
[ 554.898844] ? down_write+0x87/0x120
[ 554.898851] ? deactivate_super+0x139/0x1b0
[ 554.898857] ? down_read+0x150/0x150
[ 554.898864] ? check_same_owner+0x320/0x320
[ 554.898875] deactivate_locked_super+0x64/0xd0
[ 554.898883] deactivate_super+0x141/0x1b0
----------
Since allowing register_shrinker() callers to call unregister_shrinker()
when register_shrinker() failed can simplify error recovery path, this
patch makes unregister_shrinker() no-op when register_shrinker() failed.
Also, reset shrinker->nr_deferred in case unregister_shrinker() was
by error called twice.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Aliaksei Karaliou <akaraliou.dev@gmail.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: Glauber Costa <glauber@scylladb.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-25 11:03:35 +01:00
..
2017-06-17 06:39:36 +02:00
2017-02-26 11:07:51 +01:00
2016-03-03 15:07:18 -08:00
2015-09-08 15:35:28 -07:00
2015-04-14 16:49:03 -07:00
2015-07-17 16:39:54 -07:00
2018-01-31 12:06:09 +01:00
2015-08-14 15:56:32 -07:00
2018-01-17 09:35:26 +01:00
2017-11-24 11:26:29 +01:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-11-05 19:34:48 -08:00
2015-06-02 08:33:35 -06:00
2015-11-06 17:50:42 -08:00
2017-03-12 06:37:25 +01:00
2015-11-05 19:34:48 -08:00
2015-06-24 17:49:45 -07:00
2017-06-26 07:13:11 +02:00
2014-08-06 18:01:22 -07:00
2017-12-16 10:33:50 +01:00
2015-11-06 17:50:42 -08:00
2017-04-08 09:53:32 +02:00
2015-09-10 13:29:01 -07:00
2017-01-06 11:16:11 +01:00
2017-08-11 09:08:50 -07:00
2015-02-10 14:30:31 -08:00
2015-11-06 17:50:42 -08:00
2015-01-08 15:10:52 -08:00
2014-10-09 22:25:50 -04:00
2014-06-06 16:08:18 -07:00
2018-02-03 17:04:29 +01:00
2016-10-07 15:23:40 +02:00
2017-07-21 07:44:56 +02:00
2015-11-05 19:34:48 -08:00
2017-12-05 11:22:50 +01:00
2015-09-11 16:42:39 -07:00
2017-06-14 13:16:26 +02:00
2018-01-31 12:06:09 +01:00
2017-02-09 08:02:47 +01:00
2018-01-31 12:06:09 +01:00
2018-02-22 15:45:00 +01:00
2017-08-24 17:02:35 -07:00
2017-08-12 19:29:09 -07:00
2015-09-08 15:35:28 -07:00
2017-08-24 17:02:36 -07:00
2015-11-05 19:34:48 -08:00
2017-06-07 12:06:01 +02:00
2015-06-30 19:44:56 -07:00
2018-01-31 12:06:09 +01:00
2017-12-25 14:22:09 +01:00
2015-09-10 13:29:01 -07:00
2015-02-11 17:06:02 -08:00
2017-08-11 09:08:50 -07:00
2017-08-11 09:08:50 -07:00
2015-11-05 19:34:48 -08:00
2015-06-30 19:44:55 -07:00
2015-11-05 19:34:48 -08:00
2015-12-12 10:15:34 -08:00
2018-01-31 12:06:09 +01:00
2015-11-05 19:34:48 -08:00
2017-11-24 08:32:25 +01:00
2015-09-10 13:29:01 -07:00
2015-08-13 12:32:00 -06:00
2016-04-20 15:41:53 +09:00
2017-11-24 08:32:25 +01:00
2018-01-17 09:35:27 +01:00
2017-11-24 08:32:25 +01:00
2014-09-02 14:46:05 -04:00
2014-09-02 14:46:02 -04:00
2017-03-26 12:13:20 +02:00
2016-02-25 12:01:23 -08:00
2016-02-25 12:01:16 -08:00
2015-11-06 17:50:42 -08:00
2017-12-25 14:22:09 +01:00
2016-07-27 09:47:40 -07:00
2017-10-21 17:09:05 +02:00
2015-11-22 11:58:44 -08:00
2015-11-22 11:58:44 -08:00
2015-11-22 11:58:44 -08:00
2017-06-07 12:06:01 +02:00
2014-04-07 16:35:54 -07:00
2017-07-05 14:37:15 +02:00
2015-09-08 15:35:28 -07:00
2015-11-06 17:50:42 -08:00
2016-11-18 10:48:34 +01:00
2017-06-14 13:16:24 +02:00
2015-09-04 16:54:41 -07:00
2016-09-15 08:27:46 +02:00
2015-11-05 19:34:48 -08:00
2015-11-20 16:17:32 -08:00
2017-03-12 06:37:25 +01:00
2018-02-25 11:03:35 +01:00
2018-01-10 09:27:14 +01:00
2016-10-28 03:01:34 -04:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2016-05-18 17:06:44 -07:00
2018-01-17 09:35:27 +01:00