Borislav Petkov
251c54ea26
EDAC/ghes: Check whether the driver is on the safe list correctly
...
With CONFIG_DEBUG_TEST_DRIVER_REMOVE=y, a system would try to probe,
unregister and probe again a driver.
When ghes_edac is attempted to be loaded on a system which is not on
the safe platforms list, ghes_edac_register() would return early. The
unregister counterpart ghes_edac_unregister() would still attempt to
unregister and exit early at the refcount test, leading to the refcount
underflow below.
In order to not do *anything* on the unregister path too, reuse the
force_load parameter and check it on that path too, before fumbling with
the refcount.
ghes_edac: ghes_edac_register: entry
ghes_edac: ghes_edac_register: return -ENODEV
------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 10 PID: 1 at lib/refcount.c:28 refcount_warn_saturate+0xb9/0x100
Modules linked in:
CPU: 10 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc4+ #12
Hardware name: GIGABYTE MZ01-CE1-00/MZ01-CE1-00, BIOS F02 08/29/2018
RIP: 0010:refcount_warn_saturate+0xb9/0x100
Code: 82 e8 fb 8f 4d 00 90 0f 0b 90 90 c3 80 3d 55 4c f5 00 00 75 88 c6 05 4c 4c f5 00 01 90 48 c7 c7 d0 8a 10 82 e8 d8 8f 4d 00 90 <0f> 0b 90 90 c3 80 3d 30 4c f5 00 00 0f 85 61 ff ff ff c6 05 23 4c
RSP: 0018:ffffc90000037d58 EFLAGS: 00010292
RAX: 0000000000000026 RBX: ffff88840b8da000 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffffffff8216b24f RDI: 00000000ffffffff
RBP: ffff88840c662e00 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000046 R12: 0000000000000000
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff88840ee80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000800002211000 CR4: 00000000003506e0
Call Trace:
ghes_edac_unregister
ghes_remove
platform_drv_remove
really_probe
driver_probe_device
device_driver_attach
__driver_attach
? device_driver_attach
? device_driver_attach
bus_for_each_dev
bus_add_driver
driver_register
? bert_init
ghes_init
do_one_initcall
? rcu_read_lock_sched_held
kernel_init_freeable
? rest_init
kernel_init
ret_from_fork
...
ghes_edac: ghes_edac_unregister: FALSE, refcount: -1073741824
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200911164950.GB19320@zn.tnic
2020-09-15 09:42:15 +02:00
..
2019-11-22 10:18:29 +01:00
2019-07-25 14:28:42 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2020-08-23 17:36:59 -05:00
2020-05-22 18:43:13 +02:00
2017-07-17 13:42:48 +02:00
2019-06-05 17:37:06 +02:00
2019-06-05 17:37:06 +02:00
2020-04-24 09:08:47 +02:00
2019-06-05 17:37:06 +02:00
2020-04-14 11:28:09 +02:00
2019-12-19 07:27:09 +01:00
2019-08-08 12:57:01 -03:00
2016-12-15 08:54:51 -02:00
2019-06-05 17:37:06 +02:00
2019-08-29 07:58:01 +01:00
2020-02-19 21:00:27 +01:00
2017-07-17 13:42:48 +02:00
2018-11-10 16:56:16 +01:00
2020-06-17 15:38:35 +02:00
2019-10-09 13:01:42 +02:00
2019-10-09 13:01:42 +02:00
2020-02-17 13:37:00 +01:00
2020-06-15 11:19:52 -07:00
2020-02-17 13:05:10 +01:00
2017-10-31 15:30:37 +01:00
2020-02-17 12:32:44 +01:00
2020-06-17 15:38:35 +02:00
2016-12-24 11:46:01 -08:00
2016-12-15 08:54:51 -02:00
2018-12-19 11:57:45 +01:00
2018-12-19 11:57:45 +01:00
2020-09-15 09:42:15 +02:00
2019-05-30 11:29:52 -07:00
2019-05-30 11:29:52 -07:00
2020-08-18 15:40:30 +02:00
2020-06-15 14:50:39 -07:00
2020-01-06 09:45:59 +01:00
2020-01-06 09:45:59 +01:00
2019-11-09 10:32:32 +01:00
2019-12-16 13:54:02 -08:00
2019-11-09 10:32:32 +01:00
2019-11-09 10:32:32 +01:00
2017-07-17 13:42:48 +02:00
2017-07-17 13:42:48 +02:00
2017-07-17 13:42:48 +02:00
2020-01-06 09:45:59 +01:00
2020-08-10 11:13:06 -07:00
2020-06-14 01:57:21 +09:00
2016-12-15 08:54:51 -02:00
2020-02-19 21:00:27 +01:00
2020-06-23 17:27:53 +02:00
2020-04-14 15:53:46 +02:00
2017-02-03 10:36:35 +01:00
2016-09-01 10:28:00 +02:00
2018-01-09 20:14:23 +01:00
2016-12-15 08:54:51 -02:00
2017-11-27 11:57:26 +01:00
2016-12-15 08:54:51 -02:00
2016-12-15 08:54:51 -02:00
2019-06-05 17:37:06 +02:00
2020-08-23 17:36:59 -05:00
2019-06-05 17:36:37 +02:00
2019-06-05 17:37:17 +02:00
2019-06-05 17:37:17 +02:00
2018-11-06 12:03:16 +01:00
2017-07-17 13:42:48 +02:00
2020-08-18 15:40:30 +02:00
2020-01-27 09:16:22 -08:00
2020-06-15 14:50:39 -07:00
2020-08-18 15:40:30 +02:00
2020-06-01 11:39:15 +02:00
2020-03-17 14:32:31 +01:00
2020-04-23 12:07:24 +02:00
2019-11-09 10:32:32 +01:00
2019-05-21 10:50:45 +02:00
2020-01-06 09:45:59 +01:00
2020-04-14 14:35:19 +02:00