mirror-linux/drivers
Krzysztof Kozlowski 32f37e5758 serial: Fix not set tty->port race condition
Revert commit bfc467db60 ("serial: remove redundant
tty_port_link_device()") because the tty_port_link_device() is not
redundant: the tty->port has to be confured before we call
uart_configure_port(), otherwise user-space can open console without TTY
linked to the driver.

This tty_port_link_device() was added explicitly to avoid this exact
issue in commit fb2b90014d ("tty: link tty and port before configuring
it as console"), so offending commit basically reverted the fix saying
it is redundant without addressing the actual race condition presented
there.

Reproducible always as tty->port warning on Qualcomm SoC with most of
devices disabled, so with very fast boot, and one serial device being
the console:

  printk: legacy console [ttyMSM0] enabled
  printk: legacy console [ttyMSM0] enabled
  printk: legacy bootconsole [qcom_geni0] disabled
  printk: legacy bootconsole [qcom_geni0] disabled
  ------------[ cut here ]------------
  tty_init_dev: ttyMSM driver does not set tty->port. This would crash the kernel. Fix the driver!
  WARNING: drivers/tty/tty_io.c:1414 at tty_init_dev.part.0+0x228/0x25c, CPU#2: systemd/1
  Modules linked in: socinfo tcsrcc_eliza gcc_eliza sm3_ce fuse ipv6
  CPU: 2 UID: 0 PID: 1 Comm: systemd Tainted: G S                  6.19.0-rc4-next-20260108-00024-g2202f4d30aa8 #73 PREEMPT
  Tainted: [S]=CPU_OUT_OF_SPEC
  Hardware name: Qualcomm Technologies, Inc. Eliza (DT)
  ...
  tty_init_dev.part.0 (drivers/tty/tty_io.c:1414 (discriminator 11)) (P)
  tty_open (arch/arm64/include/asm/atomic_ll_sc.h:95 (discriminator 3) drivers/tty/tty_io.c:2073 (discriminator 3) drivers/tty/tty_io.c:2120 (discriminator 3))
  chrdev_open (fs/char_dev.c:411)
  do_dentry_open (fs/open.c:962)
  vfs_open (fs/open.c:1094)
  do_open (fs/namei.c:4634)
  path_openat (fs/namei.c:4793)
  do_filp_open (fs/namei.c:4820)
  do_sys_openat2 (fs/open.c:1391 (discriminator 3))
  ...
  Starting Network Name Resolution...

Apparently the flow with this small Yocto-based ramdisk user-space is:

driver (qcom_geni_serial.c):                  user-space:
============================                  ===========
qcom_geni_serial_probe()
 uart_add_one_port()
  serial_core_register_port()
   serial_core_add_one_port()
    uart_configure_port()
     register_console()
    |
    |                                         open console
    |                                          ...
    |                                          tty_init_dev()
    |                                           driver->ports[idx] is NULL
    |
    tty_port_register_device_attr_serdev()
     tty_port_link_device() <- set driver->ports[idx]

Fixes: bfc467db60 ("serial: remove redundant tty_port_link_device()")
Cc: stable@vger.kernel.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Link: https://patch.msgid.link/20260123072139.53293-2-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-01-23 17:23:09 +01:00
..
accel accel/amdxdna: Block running under a hypervisor 2025-12-15 13:00:03 -06:00
accessibility
acpi ACPI: PCC: Fix race condition by removing static qualifier 2025-12-15 13:00:33 +01:00
amba soc: driver updates for 6.19 2025-12-05 17:29:04 -08:00
android Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
ata ata: libata-core: Disable LPM on ST2000DM008-2FR102 2025-12-16 14:23:10 +09:00
atm
auxdisplay
base PM: runtime: Do not clear needs_force_resume with enabled runtime PM 2025-12-16 12:58:57 +01:00
bcma
block block-6.19-20251226 2025-12-26 11:44:35 -08:00
bluetooth Bluetooth: btusb: Add new VID/PID 13d3/3533 for RTL8821CE 2025-12-01 16:21:16 -05:00
bus Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
cache
cdrom
cdx
char Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
clk This pull request is entirely SoC clk drivers, not for lack of trying to modify 2025-12-08 09:38:52 +09:00
clocksource soc: driver updates for 6.19 2025-12-05 17:29:04 -08:00
comedi Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
connector
counter
cpufreq cpufreq: dt-platdev: Fix creating device on OPPv1 platforms 2025-12-16 07:59:30 -06:00
cpuidle soc: driver updates for 6.19 2025-12-05 17:29:04 -08:00
crypto tsm for 6.19 2025-12-06 10:15:41 -08:00
cxl soc: driver updates for 6.19, part 2 2025-12-05 17:47:59 -08:00
dax Significant patch series in this merge are as follows: 2025-12-05 13:52:43 -08:00
dca
devfreq
dibs
dio
dma dmaengine updates for v6.19 2025-12-09 06:35:53 +09:00
dma-buf VFIO updates for v6.19-rc1 2025-12-04 18:42:48 -08:00
dpll
edac bitmap updates for v6.19 2025-12-06 09:01:27 -08:00
eisa
extcon
firewire firewire: nosy: Fix dma_free_coherent() size 2025-12-26 22:04:03 +09:00
firmware arm64: efi: Fix NULL pointer dereference by initializing user_ns 2025-12-24 21:32:57 +01:00
fpga
fsi
fwctl
gnss
gpib
gpio gpio updates for v6.19-rc1 2025-12-13 16:36:57 +12:00
gpu Merge tag 'drm-msm-fixes-2025-12-26' of https://gitlab.freedesktop.org/drm/msm into drm-fixes 2025-12-27 16:00:47 +10:00
greybus
hid Input updates for v6.19-rc1 2025-12-21 15:21:10 -08:00
hsi
hte
hv hyperv-next for v6.19 2025-12-09 06:10:17 +09:00
hwmon hwmon: (ltc4282): Fix reset_history file permissions 2025-12-19 08:44:22 -08:00
hwspinlock
hwtracing Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
i2c i2c: i801: Add support for Intel Nova Lake-S 2025-12-17 00:28:51 +01:00
i3c i3c: adi: Fix confusing cleanup.h syntax 2025-12-12 23:59:39 +01:00
idle
iio Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
infiniband RDMA v6.19 merge window pull request 2025-12-04 18:54:37 -08:00
input Input updates for v6.19-rc1 2025-12-21 15:21:10 -08:00
interconnect
iommu Miscellaneous x86 fixes: 2025-12-21 14:41:29 -08:00
ipack
irqchip Misc fixes: 2025-12-14 06:07:09 +12:00
isdn
leds soc: driver updates for 6.19 2025-12-05 17:29:04 -08:00
macintosh soc: driver updates for 6.19 2025-12-05 17:29:04 -08:00
mailbox
mcb
md SCSI misc on 20251214 2025-12-14 15:35:35 +12:00
media Modules changes for v6.19-rc1 2025-12-06 08:27:07 -08:00
memory soc: driver updates for 6.19 2025-12-05 17:29:04 -08:00
memstick
message
mfd MFD for v6.19 2025-12-04 15:18:33 -08:00
misc lkdtm/bugs: Do not confuse the clang/objtool with busy wait loop 2025-12-19 15:09:09 +00:00
mmc mmc: sdhci-esdhc-imx: add alternate ARCH_S32 dependency to Kconfig 2025-12-17 14:14:51 +01:00
most
mtd This pull request contains the following changes for UBI and UBIFS: 2025-12-09 08:50:27 +09:00
mux
net Including fixes from netfilter and CAN. 2025-12-19 07:55:35 +12:00
nfc nfc: pn533: Fix error code in pn533_acr122_poweron_rdr() 2025-12-11 01:40:00 -08:00
ntb
nubus
nvdimm NVDIMM changes for 6.19 2025-12-06 09:32:25 -08:00
nvme block-6.19-20251208 2025-12-09 08:53:24 +09:00
nvmem Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
of arm64: kdump: Fix elfcorehdr overlap caused by reserved memory processing reorder 2025-12-16 07:59:30 -06:00
opp
parisc parisc: Set valid bit in high byte of 64‑bit physical address 2025-12-19 13:56:17 +01:00
parport
pci pci-v6.19-fixes-1 2025-12-13 16:29:22 +12:00
pcmcia
peci Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
perf arm64 updates for 6.19: 2025-12-02 17:03:55 -08:00
phy
pinctrl Pin control changes for the v6.19 kernel cycle: 2025-12-09 06:45:00 +09:00
platform platform-drivers-x86 for v6.19-1 2025-12-10 06:38:17 +09:00
pmdomain pmdomain core: 2025-12-04 13:50:39 -08:00
pnp
power soc: driver updates for 6.19 2025-12-05 17:29:04 -08:00
powercap powercap: intel_rapl: Fix possible recursive lock warning 2025-12-17 17:24:28 +01:00
pps printk changes for 6.19 2025-12-03 12:42:36 -08:00
ps3
ptp Networking changes for 6.19. 2025-12-03 17:24:33 -08:00
pwm pwm: th1520: Fix missing Kconfig dependencies 2025-12-13 16:41:50 +12:00
rapidio
ras EFI updates for v6.19: 2025-12-04 17:10:08 -08:00
regulator regulator: fp9931: fix regulator node pointer 2025-12-24 11:31:29 +00:00
remoteproc
resctrl
reset This pull request is entirely SoC clk drivers, not for lack of trying to modify 2025-12-08 09:38:52 +09:00
rpmsg
rtc RTC for 6.19 2025-12-13 17:09:06 +12:00
s390 s390: Unmap early KASAN shadow on memory offlining 2025-12-07 16:15:19 +01:00
sbus
scsi scsi: sg: Fix occasional bogus elapsed time that exceeds timeout 2025-12-16 21:24:28 -05:00
sh
siox
slimbus Networking changes for 6.19. 2025-12-03 17:24:33 -08:00
soc bitmap updates for v6.19 2025-12-06 09:01:27 -08:00
soundwire soundwire: intel_ace2x: handle multi BPT sections 2025-12-08 12:37:27 +05:30
spi spi: cadence-quadspi: Prevent indirect read 2025-12-23 15:18:22 +00:00
spmi
ssb
staging Staging driver updates for 6.19-rc1 2025-12-06 18:52:00 -08:00
target SCSI misc on 20251214 2025-12-14 15:35:35 +12:00
tc
tee
thermal thermal: core: Fix typo and indentation in comments 2025-12-15 12:47:39 +01:00
thunderbolt USB/Thunderbolt changes for 6.19-rc1 2025-12-06 18:42:12 -08:00
tty serial: Fix not set tty->port race condition 2026-01-23 17:23:09 +01:00
ufs scsi: ufs: core: Add ufshcd_update_evt_hist() for UFS suspend error 2025-12-16 22:24:36 -05:00
uio
usb Merge patch series "usb: typec: ucsi: revert broken buffer management" 2025-12-23 15:59:03 +01:00
vdpa Significant patch series in this merge are as follows: 2025-12-05 13:52:43 -08:00
vfio drm next part 2 for 6.19-rc1 2025-12-04 19:42:53 -08:00
vhost vhost/vsock: improve RCU read sections around vhost_vsock_get() 2025-12-24 08:02:57 -05:00
video fbdev fixes & enhancements for 6.19-rc1: 2025-12-06 15:41:26 -08:00
virt virt: Fix Kconfig warning when selecting TSM without VIRT_DRIVERS 2025-12-04 17:34:16 -08:00
virtio
w1
watchdog linux-watchdog 6.19-rc1 tag 2025-12-06 10:00:49 -08:00
xen xen: branch for v6.19-rc1 2025-12-06 10:49:19 -08:00
zorro
Kconfig Staging driver updates for 6.19-rc1 2025-12-06 18:52:00 -08:00
Makefile Staging driver updates for 6.19-rc1 2025-12-06 18:52:00 -08:00