linux-stable/Documentation
Jiri Pirko 53c0441dd2 dpll: fix possible deadlock during netlink dump operation
Recently, I've been hitting following deadlock warning during dpll pin
dump:

[52804.637962] ======================================================
[52804.638536] WARNING: possible circular locking dependency detected
[52804.639111] 6.8.0-rc2jiri+ #1 Not tainted
[52804.639529] ------------------------------------------------------
[52804.640104] python3/2984 is trying to acquire lock:
[52804.640581] ffff88810e642678 (nlk_cb_mutex-GENERIC){+.+.}-{3:3}, at: netlink_dump+0xb3/0x780
[52804.641417]
               but task is already holding lock:
[52804.642010] ffffffff83bde4c8 (dpll_lock){+.+.}-{3:3}, at: dpll_lock_dumpit+0x13/0x20
[52804.642747]
               which lock already depends on the new lock.

[52804.643551]
               the existing dependency chain (in reverse order) is:
[52804.644259]
               -> #1 (dpll_lock){+.+.}-{3:3}:
[52804.644836]        lock_acquire+0x174/0x3e0
[52804.645271]        __mutex_lock+0x119/0x1150
[52804.645723]        dpll_lock_dumpit+0x13/0x20
[52804.646169]        genl_start+0x266/0x320
[52804.646578]        __netlink_dump_start+0x321/0x450
[52804.647056]        genl_family_rcv_msg_dumpit+0x155/0x1e0
[52804.647575]        genl_rcv_msg+0x1ed/0x3b0
[52804.648001]        netlink_rcv_skb+0xdc/0x210
[52804.648440]        genl_rcv+0x24/0x40
[52804.648831]        netlink_unicast+0x2f1/0x490
[52804.649290]        netlink_sendmsg+0x36d/0x660
[52804.649742]        __sock_sendmsg+0x73/0xc0
[52804.650165]        __sys_sendto+0x184/0x210
[52804.650597]        __x64_sys_sendto+0x72/0x80
[52804.651045]        do_syscall_64+0x6f/0x140
[52804.651474]        entry_SYSCALL_64_after_hwframe+0x46/0x4e
[52804.652001]
               -> #0 (nlk_cb_mutex-GENERIC){+.+.}-{3:3}:
[52804.652650]        check_prev_add+0x1ae/0x1280
[52804.653107]        __lock_acquire+0x1ed3/0x29a0
[52804.653559]        lock_acquire+0x174/0x3e0
[52804.653984]        __mutex_lock+0x119/0x1150
[52804.654423]        netlink_dump+0xb3/0x780
[52804.654845]        __netlink_dump_start+0x389/0x450
[52804.655321]        genl_family_rcv_msg_dumpit+0x155/0x1e0
[52804.655842]        genl_rcv_msg+0x1ed/0x3b0
[52804.656272]        netlink_rcv_skb+0xdc/0x210
[52804.656721]        genl_rcv+0x24/0x40
[52804.657119]        netlink_unicast+0x2f1/0x490
[52804.657570]        netlink_sendmsg+0x36d/0x660
[52804.658022]        __sock_sendmsg+0x73/0xc0
[52804.658450]        __sys_sendto+0x184/0x210
[52804.658877]        __x64_sys_sendto+0x72/0x80
[52804.659322]        do_syscall_64+0x6f/0x140
[52804.659752]        entry_SYSCALL_64_after_hwframe+0x46/0x4e
[52804.660281]
               other info that might help us debug this:

[52804.661077]  Possible unsafe locking scenario:

[52804.661671]        CPU0                    CPU1
[52804.662129]        ----                    ----
[52804.662577]   lock(dpll_lock);
[52804.662924]                                lock(nlk_cb_mutex-GENERIC);
[52804.663538]                                lock(dpll_lock);
[52804.664073]   lock(nlk_cb_mutex-GENERIC);
[52804.664490]

The issue as follows: __netlink_dump_start() calls control->start(cb)
with nlk->cb_mutex held. In control->start(cb) the dpll_lock is taken.
Then nlk->cb_mutex is released and taken again in netlink_dump(), while
dpll_lock still being held. That leads to ABBA deadlock when another
CPU races with the same operation.

Fix this by moving dpll_lock taking into dumpit() callback which ensures
correct lock taking order.

Fixes: 9d71b54b65 ("dpll: netlink: Add DPLL framework base functions")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Link: https://lore.kernel.org/r/20240207115902.371649-1-jiri@resnulli.us
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-02-08 18:29:21 -08:00
..
ABI drm fixes for 6.8-rc3 2024-02-02 12:54:46 -08:00
PCI docs: PCI: Fix typos 2023-12-28 17:37:36 -06:00
RAS
RCU
accel docs/accel: correct links to mailing list archives 2024-01-23 14:45:50 -07:00
accounting
admin-guide docs: admin-guide: remove obsolete advice related to SLAB allocator 2024-01-23 14:52:37 -07:00
arch arm64 fixes for -rc1 2024-01-19 13:36:15 -08:00
block Documentation: block: ioprio: Update schedulers 2024-01-18 08:21:14 -07:00
bpf Another moderately busy cycle for documentation, including: 2024-01-11 19:46:52 -08:00
cdrom
core-api A handful of late-arriving documentation fixes. 2024-01-17 11:49:11 -08:00
cpu-freq
crypto Another moderately busy cycle for documentation, including: 2024-01-11 19:46:52 -08:00
dev-tools Documentation: KUnit: Update the instructions on how to test static functions 2024-01-22 07:59:03 -07:00
devicetree ALSA: Various fixes for Cirrus Logic CS35L56 support 2024-02-01 17:45:32 +00:00
doc-guide
driver-api pci-v6.8-changes 2024-01-17 16:23:17 -08:00
fault-injection
fb fbdev/intelfb: Remove driver 2024-01-12 12:38:37 +01:00
features riscv: Add support for BATCHED_UNMAP_TLB_FLUSH 2024-01-11 08:01:53 -08:00
filesystems ovl: mark xwhiteouts directory with overlay.opaque='x' 2024-01-23 12:39:48 +02:00
firmware-guide
firmware_class
fpga
gpu amd-drm-next-6.8-2024-01-05: 2024-01-09 09:07:50 +10:00
hid
hwmon hwmon: (lm75) Add AMS AS6200 temperature sensor 2024-01-02 08:44:57 -08:00
i2c Documentation/i2c: fix spelling error in i2c-address-translators 2023-12-27 20:05:44 +01:00
iio
images
infiniband
input
isdn
kbuild
kernel-hacking
leds
litmus-tests
livepatch
locking locking/mutex: Clarify that mutex_unlock(), and most other sleeping locks, can still use the lock object after it's unlocked 2024-01-08 09:55:31 +01:00
maintainer
mhi
misc-devices
mm mm/rmap: rename COMPOUND_MAPPED to ENTIRELY_MAPPED 2023-12-29 11:58:56 -08:00
netlabel
netlink dpll: fix possible deadlock during netlink dump operation 2024-02-08 18:29:21 -08:00
networking Another moderately busy cycle for documentation, including: 2024-01-11 19:46:52 -08:00
nvdimm
nvme
pcmcia
peci
power Documentation: PM: Adjust freezing-of-tasks.rst to the freezer changes 2023-12-19 21:14:32 +01:00
process Kbuild updates for v6.8 2024-01-18 17:57:07 -08:00
rust LoongArch changes for v6.8 2024-01-19 13:30:49 -08:00
scheduler sched/fair: Remove SCHED_FEAT(UTIL_EST_FASTUP, true) 2023-12-23 15:59:56 +01:00
scsi
security
sound
sphinx docs/sphinx: Fix TOC scroll hack for the home page 2024-01-23 14:33:13 -07:00
sphinx-static docs: translations: add translations links when they exist 2023-12-19 14:34:59 -07:00
spi
staging rpmsg updates for v6.8 2024-01-17 15:05:27 -08:00
target
tee
timers
tools
trace tracing updates for 6.8: 2024-01-18 14:35:29 -08:00
translations A handful of late-arriving documentation fixes. 2024-01-17 11:49:11 -08:00
usb usb: gadget: ncm: Fix indentations in documentation of NCM section 2024-01-27 16:27:58 -08:00
userspace-api fbdev fixes and cleanups for 6.8-rc1: 2024-01-12 14:38:08 -08:00
virt KVM x86 MMU changes for 6.8: 2024-01-08 08:10:32 -05:00
w1
watchdog
wmi
.gitignore
Changes
CodingStyle
Kconfig
Makefile doc/netlink: Regenerate netlink .rst files if ynl-gen-rst changes 2023-12-18 14:39:44 -08:00
SubmittingPatches
atomic_bitops.txt
atomic_t.txt
conf.py docs: translations: add translations links when they exist 2023-12-19 14:34:59 -07:00
docutils.conf
dontdiff
index.rst
memory-barriers.txt
subsystem-apis.rst