Dave Jiang
471b12c43f
driver core: auxiliary bus: Fix calling stage for auxiliary bus init
When the auxiliary device code is built into the kernel, it can be executed
before the auxiliary bus is registered. This causes bus->p to be not
allocated and triggers a NULL pointer dereference when the auxiliary bus
device gets added with bus_add_device(). Call the auxiliary_bus_init()
under driver_init() so the bus is initialized before devices.
Below is the kernel splat for the bug:
[ 1.948215] BUG: kernel NULL pointer dereference, address: 0000000000000060
[ 1.950670] #PF: supervisor read access in kernel mode
[ 1.950670] #PF: error_code(0x0000) - not-present page
[ 1.950670] PGD 0
[ 1.950670] Oops: 0000 1 SMP NOPTI
[ 1.950670] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0-intel-nextsvmtest+ #2205
[ 1.950670] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[ 1.950670] RIP: 0010:bus_add_device+0x64/0x140
[ 1.950670] Code: 00 49 8b 75 20 48 89 df e8 59 a1 ff ff 41 89 c4 85 c0 75 7b 48 8b 53 50 48 85 d2 75 03 48 8b 13 49 8b 85 a0 00 00 00 48 89 de <48> 8
78 60 48 83 c7 18 e8 ef d9 a9 ff 41 89 c4 85 c0 75 45 48 8b
[ 1.950670] RSP: 0000:ff46032ac001baf8 EFLAGS: 00010246
[ 1.950670] RAX: 0000000000000000 RBX: ff4597f7414aa680 RCX: 0000000000000000
[ 1.950670] RDX: ff4597f74142bbc0 RSI: ff4597f7414aa680 RDI: ff4597f7414aa680
[ 1.950670] RBP: ff46032ac001bb10 R08: 0000000000000044 R09: 0000000000000228
[ 1.950670] R10: ff4597f741141b30 R11: ff4597f740182a90 R12: 0000000000000000
[ 1.950670] R13: ffffffffa5e936c0 R14: 0000000000000000 R15: 0000000000000000
[ 1.950670] FS: 0000000000000000(0000) GS:ff4597f7bba00000(0000) knlGS:0000000000000000
[ 1.950670] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1.950670] CR2: 0000000000000060 CR3: 000000002140c001 CR4: 0000000000f71ef0
[ 1.950670] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1.950670] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
[ 1.950670] PKRU: 55555554
[ 1.950670] Call Trace:
[ 1.950670] device_add+0x3ee/0x850
[ 1.950670] __auxiliary_device_add+0x47/0x60
[ 1.950670] idxd_pci_probe+0xf77/0x1180
[ 1.950670] local_pci_probe+0x4a/0x90
[ 1.950670] pci_device_probe+0xff/0x1b0
[ 1.950670] really_probe+0x1cf/0x440
[ 1.950670] ? rdinit_setup+0x31/0x31
[ 1.950670] driver_probe_device+0xe8/0x150
[ 1.950670] device_driver_attach+0x58/0x60
[ 1.950670] __driver_attach+0x8f/0x150
[ 1.950670] ? device_driver_attach+0x60/0x60
[ 1.950670] ? device_driver_attach+0x60/0x60
[ 1.950670] bus_for_each_dev+0x79/0xc0
[ 1.950670] ? kmem_cache_alloc_trace+0x323/0x430
[ 1.950670] driver_attach+0x1e/0x20
[ 1.950670] bus_add_driver+0x154/0x1f0
[ 1.950670] driver_register+0x70/0xc0
[ 1.950670] __pci_register_driver+0x54/0x60
[ 1.950670] idxd_init_module+0xe2/0xfc
[ 1.950670] ? idma64_platform_driver_init+0x19/0x19
[ 1.950670] do_one_initcall+0x4a/0x1e0
[ 1.950670] kernel_init_freeable+0x1fc/0x25c
[ 1.950670] ? rest_init+0xba/0xba
[ 1.950670] kernel_init+0xe/0x116
[ 1.950670] ret_from_fork+0x1f/0x30
[ 1.950670] Modules linked in:
[ 1.950670] CR2: 0000000000000060
[ 1.950670] --[ end trace cd7d1b226d3ca901 ]--
Fixes: 7de3697e9c ("Add auxiliary bus support")
Reported-by: Jacob Pan <jacob.jun.pan@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Dave Ertman <david.m.ertman@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20210210201611.1611074-1-dave.jiang@intel.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-11 08:43:03 +01:00
..
2020-12-09 15:38:13 +01:00
2021-01-20 19:20:20 +01:00
2020-12-15 19:29:43 -08:00
2020-12-21 17:34:09 -08:00
2021-02-11 08:43:03 +01:00
2021-01-08 08:19:18 -07:00
2020-12-07 17:01:54 +02:00
2020-12-16 16:38:41 -08:00
2020-12-12 11:12:25 -07:00
2020-12-18 12:38:28 -08:00
2021-02-09 14:31:07 +01:00
2020-12-16 00:07:17 -08:00
2020-12-16 11:06:49 -08:00
2021-01-14 20:56:56 +00:00
2021-01-07 18:22:46 +01:00
2020-12-16 16:38:41 -08:00
2021-01-08 15:37:55 +11:00
2020-12-24 12:18:11 -08:00
2020-12-15 15:27:16 +01:00
2021-01-04 21:27:45 +05:30
2021-01-10 23:08:21 +05:30
2020-12-15 12:53:37 -08:00
2020-12-11 17:18:10 +09:00
2020-12-24 12:40:07 -08:00
2020-12-07 10:08:14 +01:00
2020-12-15 16:06:14 -08:00
2021-02-09 14:26:21 +01:00
2021-01-22 09:43:21 +10:00
2021-01-14 13:27:35 +01:00
2020-12-02 22:35:44 +01:00
2021-01-05 17:52:04 +00:00
2021-01-08 07:31:03 -08:00
2020-12-10 13:34:40 -06:00
2021-01-21 18:54:43 +01:00
2021-01-22 10:13:33 +01:00
2020-12-17 10:31:30 +01:00
2021-01-01 12:58:07 -08:00
2020-12-30 18:25:34 +01:00
2021-01-14 21:01:22 +00:00
2021-01-14 12:53:13 -04:00
2020-12-15 16:18:23 -08:00
2020-12-28 14:03:02 +02:00
2021-01-12 16:56:20 +00:00
2021-01-12 21:23:55 +01:00
2021-01-05 15:50:36 -08:00
2021-01-21 05:45:51 -07:00
2020-12-07 10:48:16 +01:00
2020-12-09 19:26:02 -06:00
2021-01-24 12:24:35 -08:00
2020-12-16 16:38:41 -08:00
2020-12-09 00:40:02 +01:00
2020-12-04 12:27:10 +01:00
2020-12-16 13:34:31 -08:00
2020-12-26 09:19:49 -08:00
2021-01-22 11:04:53 +01:00
2021-01-15 12:09:15 +01:00
2021-01-20 23:38:00 +01:00
2021-01-20 09:16:01 -08:00
2020-12-16 13:09:35 -08:00
2020-12-27 09:22:55 -08:00
2020-12-16 16:53:00 -08:00
2021-01-20 18:56:33 +01:00
2021-02-09 14:31:06 +01:00
2020-12-28 10:56:22 +05:30
2020-12-25 20:17:40 -08:00
2020-12-19 12:50:10 -08:00
2021-01-13 15:08:41 +00:00
2021-01-04 13:00:54 +05:30
2021-01-18 16:07:08 +01:00
2021-01-18 21:42:01 +01:00
2020-12-13 01:00:10 +01:00
2020-12-15 15:26:14 +01:00
2020-12-15 22:50:12 +11:00
2021-01-06 16:17:23 -08:00
2020-12-19 11:51:32 -08:00
2020-12-15 22:46:18 -08:00
2021-01-04 16:23:20 +00:00
2020-12-16 16:38:41 -08:00
2020-12-16 16:38:41 -08:00
2020-12-20 10:12:06 -08:00
2021-01-07 18:54:06 -08:00
2021-01-14 22:02:59 -05:00
2021-01-06 19:55:29 -05:00
2020-12-10 16:17:15 +01:00
2020-12-10 16:23:56 +01:00
2021-01-14 09:34:00 +09:00
2020-12-05 13:11:54 +05:30
2021-01-15 14:14:38 +00:00
2020-12-10 10:45:36 +01:00
2021-01-06 17:39:38 +01:00
2021-01-23 11:35:02 -08:00
2020-12-16 16:38:41 -08:00
2020-12-18 12:19:37 -08:00
2021-01-07 15:14:44 +03:00
2021-01-24 10:56:45 -08:00
2020-12-09 19:59:00 +01:00
2021-01-19 14:10:46 +01:00
2020-12-24 12:06:46 -08:00
2020-12-20 10:44:05 -08:00
2021-01-05 13:30:28 -08:00
2020-12-18 12:38:28 -08:00
2020-12-24 12:06:46 -08:00
2020-12-09 19:44:34 +01:00
2020-12-23 15:01:49 -08:00
2021-01-15 10:52:00 -08:00
2020-12-16 00:07:17 -08:00