serial: 8250: force synchronous probe for the ISA and PNP drivers
PATCH 1/1 serial: 8250: force synchronous probe for the ISA and PNP drivers
On x86_64 defconfig, booting with driver_async_probe=serial hangs in early init. The 8250 PNP driver is put onto the async probe pool. serial8250_register_8250_port() runs in a kworker concurrently with the ISA registration done from the serial8250_init() initcall resulting in a deadlock or NULL dereference.
- Deadlock: serial_core_register_port() holds port_mutex across serial_core_add_one_port()
uart_configure_port()
autoconfig_irq()
probe_irq_on()
async_synchronize_full(),
which waits for the async probe pool to drain.
The async PNP worker reaches the "port already in use" check and tries to unregister it. serial8250_register_8250_port()
uart_remove_one_port()
serial_core_unregister_port()
This blocks on port_mutex.
The init thread waits for the worker and the worker waits for the init thread.
- NULL deref: when the worker instead observes a slot whose port.dev is set but whose port_dev has not yet been populated, it hits the null pointer on the call to serial_core_get_ctrl_dev() in serial_core_unregister_port().
---
Found while experimenting with driver_async_probe=* to improve boot time.
Tested on x86_64 defconfig under QEMU + KVM with driver_async_probe=serial.
drivers/tty/serial/8250/8250_platform.c | 1 + drivers/tty/serial/8250/8250_pnp.c | 1 + 2 files changed, 2 insertions(+)
drivers/tty/serial/8250/8250_platform.c +1 -0
@@ -284,6 +284,7 @@ static struct platform_driver serial8250_isa_driver = { .driver = { .name = "serial8250", .acpi_match_table = acpi_platform_serial_table, + .probe_type = PROBE_FORCE_SYNCHRONOUS, }, };
drivers/tty/serial/8250/8250_pnp.c +1 -0
@@ -521,6 +521,7 @@ static struct pnp_driver serial_pnp_driver = { .remove = serial_pnp_remove, .driver = { .pm = pm_sleep_ptr(&serial_pnp_pm_ops), + .probe_type = PROBE_FORCE_SYNCHRONOUS, }, .id_table = pnp_dev_table, };
base-commit: eb3f4b7426cfd2b79d65b7d37155480b32259a11
Signature · 1 line
2.43.0