linux-kernelorg-stable/drivers
Jeongjun Park 2efe41234d ptp: prevent possible ABBA deadlock in ptp_clock_freerun()
syzbot reported the following ABBA deadlock:

       CPU0                           CPU1
       ----                           ----
  n_vclocks_store()
    lock(&ptp->n_vclocks_mux) [1]
        (physical clock)
                                     pc_clock_adjtime()
                                       lock(&clk->rwsem) [2]
                                        (physical clock)
                                       ...
                                       ptp_clock_freerun()
                                         ptp_vclock_in_use()
                                           lock(&ptp->n_vclocks_mux) [3]
                                              (physical clock)
    ptp_clock_unregister()
      posix_clock_unregister()
        lock(&clk->rwsem) [4]
          (virtual clock)

Since ptp virtual clock is registered only under ptp physical clock, both
ptp_clock and posix_clock must be physical clocks for ptp_vclock_in_use()
to lock &ptp->n_vclocks_mux and check ptp->n_vclocks.

However, when unregistering vclocks in n_vclocks_store(), the locking
ptp->n_vclocks_mux is a physical clock lock, but clk->rwsem of
ptp_clock_unregister() called through device_for_each_child_reverse()
is a virtual clock lock.

Therefore, clk->rwsem used in CPU0 and clk->rwsem used in CPU1 are
different locks, but in lockdep, a false positive occurs because the
possibility of deadlock is determined through lock-class.

To solve this, lock subclass annotation must be added to the posix_clock
rwsem of the vclock.

Reported-by: syzbot+7cfb66a237c4a5fb22ad@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7cfb66a237c4a5fb22ad
Fixes: 73f37068d5 ("ptp: support ptp physical/virtual clocks conversion")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20250728062649.469882-1-aha310510@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-08-12 14:17:35 -07:00
..
accel drm for 6.17-rc1 2025-07-30 19:26:49 -07:00
accessibility
acpi Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
amba
android Char / Misc / IIO / other driver updates for 6.17-rc1 2025-07-29 09:52:01 -07:00
ata ata: pata_pdc2027x: Remove space before newline and abbreviations 2025-08-01 08:43:11 +09:00
atm
auxdisplay
base Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
bcma
block Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
bluetooth
bus soc: driver updates for 6.17 2025-07-29 11:13:27 -07:00
cache
cdrom
cdx
char Some small fixes for the IPMI driver 2025-08-07 07:38:25 +03:00
clk This is the usual collection of primarily clk driver updates. The big part of 2025-07-31 13:36:27 -07:00
clocksource A treewide cleanup of struct cycle_counter const annotations: 2025-07-29 14:02:53 -07:00
comedi Char / Misc / IIO / other driver updates for 6.17-rc1 2025-07-29 09:52:01 -07:00
connector
counter
cpufreq Rust changes for v6.17 2025-08-03 13:49:10 -07:00
cpuidle pmdomain core: 2025-07-29 11:42:31 -07:00
crypto This update includes the following changes: 2025-07-31 09:45:28 -07:00
cxl Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
dax
dca
devfreq
dio
dma dmaengine updates for v6.17 2025-08-01 12:35:12 -07:00
dma-buf drm for 6.17-rc1 2025-07-30 19:26:49 -07:00
dpll dpll: zl3073x: ZL3073X_I2C and ZL3073X_SPI should depend on NET 2025-08-04 17:22:55 -07:00
edac - i10nm: 2025-07-29 16:30:38 -07:00
eisa
extcon
firewire
firmware arm64 updates for 6.17: 2025-07-29 20:21:54 -07:00
fpga
fsi Driver core changes for 6.17-rc1 2025-07-29 12:15:39 -07:00
fwctl
gnss
gpio gpio updates for v6.17-rc1 2025-07-28 21:58:46 -07:00
gpu drm fixes for 6.17-rc1 2025-08-08 06:48:14 +03:00
greybus
hid Input updates for v6.17-rc0 2025-08-07 07:40:01 +03:00
hsi
hte
hv ARM: 2025-07-30 17:14:01 -07:00
hwmon This is the usual collection of primarily clk driver updates. The big part of 2025-07-31 13:36:27 -07:00
hwspinlock
hwtracing
i2c i2c: muxes: mule: Fix an error handling path in mule_i2c_mux_probe() 2025-08-03 22:47:57 +02:00
i3c i3c: add missing include to internal header 2025-07-31 02:25:17 +02:00
idle
iio This is the usual collection of primarily clk driver updates. The big part of 2025-07-31 13:36:27 -07:00
infiniband RDMA v6.17 merge window second pull request 2025-08-07 07:36:23 +03:00
input Input updates for v6.17-rc0 2025-08-07 07:40:01 +03:00
interconnect Char / Misc / IIO / other driver updates for 6.17-rc1 2025-07-29 09:52:01 -07:00
iommu pci-v6.17-changes 2025-08-01 13:59:07 -07:00
ipack
irqchip ARM: 2025-07-30 17:14:01 -07:00
isdn
leds LEDs for for v6.17 2025-07-31 11:54:01 -07:00
macintosh
mailbox
mcb
md dm-table: fix checking for request-based stackable devices 2025-08-04 08:58:53 -07:00
media media: venus: Fix OPP table error handling 2025-08-06 04:57:14 +03:00
memory
memstick
message
mfd MFD for v6.17 2025-07-31 11:50:25 -07:00
misc pci-v6.17-changes 2025-08-01 13:59:07 -07:00
mmc MMC core: 2025-07-29 12:05:38 -07:00
most
mtd * MTD changes: 2025-07-31 13:43:02 -07:00
mux hardening updates for v6.17-rc1 2025-07-28 17:16:12 -07:00
net net: stmmac: thead: Get and enable APB clock on initialization 2025-08-12 12:52:21 +02:00
nfc
ntb
nubus
nvdimm Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
nvme for-6.17/block-20250728 2025-07-28 16:43:54 -07:00
nvmem Driver core changes for 6.17-rc1 2025-07-29 12:15:39 -07:00
of ARM: 2025-07-30 17:14:01 -07:00
opp
parisc
parport
pci powerpc fixes for 6.17 #2 2025-08-03 19:15:04 -07:00
pcmcia
peci
perf
phy phy-for-6.17 2025-08-01 12:31:50 -07:00
pinctrl Pin control changes for v6.17 2025-08-02 12:07:09 -07:00
platform [GIT PULL for v6.17] media updates 2025-07-31 13:16:09 -07:00
pmdomain
pnp
power power supply and reset changes for the 6.17 series 2025-07-31 21:39:01 -07:00
powercap platform-drivers-x86 for v6.17-1 2025-07-28 23:21:28 -07:00
pps
ps3
ptp ptp: prevent possible ABBA deadlock in ptp_clock_freerun() 2025-08-12 14:17:35 -07:00
pwm This is the usual collection of primarily clk driver updates. The big part of 2025-07-31 13:36:27 -07:00
rapidio
ras
regulator power supply and reset changes for the 6.17 series 2025-07-31 21:39:01 -07:00
remoteproc remoteproc updates for v6.17 2025-08-01 15:02:25 -07:00
reset This is the usual collection of primarily clk driver updates. The big part of 2025-07-31 13:36:27 -07:00
rpmsg remoteproc updates for v6.17 2025-08-01 15:02:25 -07:00
rtc RTC for 6.17 2025-08-03 20:17:34 -07:00
s390 more s390 updates for 6.17 merge window 2025-08-08 06:56:55 +03:00
sbus
scsi SCSI misc on 20250806 2025-08-06 15:44:25 +03:00
sh
siox
slimbus
soc drm for 6.17-rc1 2025-07-30 19:26:49 -07:00
soundwire soundwire updates for 6.17 2025-08-01 11:09:27 -07:00
spi * MTD changes: 2025-07-31 13:43:02 -07:00
spmi
ssb
staging [GIT PULL for v6.17] media updates 2025-07-31 13:16:09 -07:00
target SCSI misc on 20250806 2025-08-06 15:44:25 +03:00
tc
tee
thermal Driver core changes for 6.17-rc1 2025-07-29 12:15:39 -07:00
thunderbolt
tty DT updates for ralink, mobileye and ralink 2025-07-31 11:08:55 -07:00
ufs SCSI misc on 20250806 2025-08-06 15:44:25 +03:00
uio
usb Driver core changes for 6.17-rc1 2025-07-29 12:15:39 -07:00
vdpa vdpa: Fix IDR memory leak in VDUSE module exit 2025-08-01 09:11:08 -04:00
vfio VFIO updates for v6.17-rc1 v2 2025-08-07 07:32:50 +03:00
vhost vhost: initialize vq->nheads properly 2025-08-05 05:57:40 -04:00
video fbdev fixes for 6.17-rc1: 2025-08-08 06:43:20 +03:00
virt - Map the SNP calling area pages too so that OVMF EFI fw can issue SVSM 2025-07-29 17:18:46 -07:00
virtio virtio, vhost: features, fixes 2025-08-01 14:17:48 -07:00
w1
watchdog watchdog: sbsa: Adjust keepalive timeout to avoid MediaTek WS0 race condition 2025-07-28 12:07:08 +02:00
xen
zorro
Kconfig drm for 6.17-rc1 2025-07-30 19:26:49 -07:00
Makefile