From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Rik van Riel <riel@surriel.com>,
Konstantin Ovsepian <ovs@meta.com>,
Christoph Hellwig <hch@lst.de>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1 006/101] dma-debug: avoid deadlock between dma debug vs printk and netconsole
Date: Thu, 5 Sep 2024 11:40:38 +0200 [thread overview]
Message-ID: <20240905093716.330629304@linuxfoundation.org> (raw)
In-Reply-To: <20240905093716.075835938@linuxfoundation.org>
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rik van Riel <riel@surriel.com>
[ Upstream commit bd44ca3de49cc1badcff7a96010fa2c64f04868c ]
Currently the dma debugging code can end up indirectly calling printk
under the radix_lock. This happens when a radix tree node allocation
fails.
This is a problem because the printk code, when used together with
netconsole, can end up inside the dma debugging code while trying to
transmit a message over netcons.
This creates the possibility of either a circular deadlock on the same
CPU, with that CPU trying to grab the radix_lock twice, or an ABBA
deadlock between different CPUs, where one CPU grabs the console lock
first and then waits for the radix_lock, while the other CPU is holding
the radix_lock and is waiting for the console lock.
The trace captured by lockdep is of the ABBA variant.
-> #2 (&dma_entry_hash[i].lock){-.-.}-{2:2}:
_raw_spin_lock_irqsave+0x5a/0x90
debug_dma_map_page+0x79/0x180
dma_map_page_attrs+0x1d2/0x2f0
bnxt_start_xmit+0x8c6/0x1540
netpoll_start_xmit+0x13f/0x180
netpoll_send_skb+0x20d/0x320
netpoll_send_udp+0x453/0x4a0
write_ext_msg+0x1b9/0x460
console_flush_all+0x2ff/0x5a0
console_unlock+0x55/0x180
vprintk_emit+0x2e3/0x3c0
devkmsg_emit+0x5a/0x80
devkmsg_write+0xfd/0x180
do_iter_readv_writev+0x164/0x1b0
vfs_writev+0xf9/0x2b0
do_writev+0x6d/0x110
do_syscall_64+0x80/0x150
entry_SYSCALL_64_after_hwframe+0x4b/0x53
-> #0 (console_owner){-.-.}-{0:0}:
__lock_acquire+0x15d1/0x31a0
lock_acquire+0xe8/0x290
console_flush_all+0x2ea/0x5a0
console_unlock+0x55/0x180
vprintk_emit+0x2e3/0x3c0
_printk+0x59/0x80
warn_alloc+0x122/0x1b0
__alloc_pages_slowpath+0x1101/0x1120
__alloc_pages+0x1eb/0x2c0
alloc_slab_page+0x5f/0x150
new_slab+0x2dc/0x4e0
___slab_alloc+0xdcb/0x1390
kmem_cache_alloc+0x23d/0x360
radix_tree_node_alloc+0x3c/0xf0
radix_tree_insert+0xf5/0x230
add_dma_entry+0xe9/0x360
dma_map_page_attrs+0x1d2/0x2f0
__bnxt_alloc_rx_frag+0x147/0x180
bnxt_alloc_rx_data+0x79/0x160
bnxt_rx_skb+0x29/0xc0
bnxt_rx_pkt+0xe22/0x1570
__bnxt_poll_work+0x101/0x390
bnxt_poll+0x7e/0x320
__napi_poll+0x29/0x160
net_rx_action+0x1e0/0x3e0
handle_softirqs+0x190/0x510
run_ksoftirqd+0x4e/0x90
smpboot_thread_fn+0x1a8/0x270
kthread+0x102/0x120
ret_from_fork+0x2f/0x40
ret_from_fork_asm+0x11/0x20
This bug is more likely than it seems, because when one CPU has run out
of memory, chances are the other has too.
The good news is, this bug is hidden behind the CONFIG_DMA_API_DEBUG, so
not many users are likely to trigger it.
Signed-off-by: Rik van Riel <riel@surriel.com>
Reported-by: Konstantin Ovsepian <ovs@meta.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/dma/debug.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 3ff7089d11a92..de02c0808fb83 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -445,8 +445,11 @@ void debug_dma_dump_mappings(struct device *dev)
* dma_active_cacheline entry to track per event. dma_map_sg(), on the
* other hand, consumes a single dma_debug_entry, but inserts 'nents'
* entries into the tree.
+ *
+ * Use __GFP_NOWARN because the printk from an OOM, to netconsole, could end
+ * up right back in the DMA debugging code, leading to a deadlock.
*/
-static RADIX_TREE(dma_active_cacheline, GFP_ATOMIC);
+static RADIX_TREE(dma_active_cacheline, GFP_ATOMIC | __GFP_NOWARN);
static DEFINE_SPINLOCK(radix_lock);
#define ACTIVE_CACHELINE_MAX_OVERLAP ((1 << RADIX_TREE_MAX_TAGS) - 1)
#define CACHELINE_PER_PAGE_SHIFT (PAGE_SHIFT - L1_CACHE_SHIFT)
--
2.43.0
next prev parent reply other threads:[~2024-09-05 10:00 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 9:40 [PATCH 6.1 000/101] 6.1.109-rc1 review Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 001/101] drm: panel-orientation-quirks: Add quirk for OrangePi Neo Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 002/101] scsi: ufs: core: Bypass quick recovery if force reset is needed Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 003/101] ALSA: hda/generic: Add a helper to mute speakers at suspend/shutdown Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 004/101] ALSA: hda/conexant: Mute speakers at suspend / shutdown Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 005/101] i2c: Fix conditional for substituting empty ACPI functions Greg Kroah-Hartman
2024-09-05 9:40 ` Greg Kroah-Hartman [this message]
2024-09-05 9:40 ` [PATCH 6.1 007/101] net: usb: qmi_wwan: add MeiG Smart SRM825L Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 008/101] ASoC: amd: yc: Support mic on Lenovo Thinkpad E14 Gen 6 Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 009/101] mptcp: make pm_remove_addrs_and_subflows static Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 010/101] mptcp: pm: fix RM_ADDR ID for the initial subflow Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 011/101] PCI/MSI: Fix UAF in msi_capability_init Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 012/101] f2fs: fix to truncate preallocated blocks in f2fs_file_open() Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 013/101] mptcp: pm: fullmesh: select the right ID later Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 014/101] mptcp: pm: avoid possible UaF when selecting endp Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 015/101] mptcp: pm: reuse ID 0 after delete and re-add Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 016/101] mptcp: pm: fix ID 0 endp usage after multiple re-creations Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 017/101] selftests: mptcp: join: validate fullmesh endp on 1st sf Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 018/101] selftests: mptcp: join: check re-using ID of closed subflow Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 019/101] selftests: mptcp: add explicit test case for remove/readd Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 020/101] selftests: mptcp: join: test for flush/re-add endpoints Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 021/101] selftests: mptcp: join: check re-using ID of unused ADD_ADDR Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 022/101] selftests: mptcp: join: check re-adding init endp with != id Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 023/101] mptcp: pr_debug: add missing \n at the end Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 024/101] mptcp: avoid duplicated SUB_CLOSED events Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 025/101] selftests: mptcp: join: check removing ID 0 endpoint Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 026/101] selftests: mptcp: join: no extra msg if no counter Greg Kroah-Hartman
2024-09-05 9:40 ` [PATCH 6.1 027/101] selftests: mptcp: join: check re-re-adding ID 0 endp Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 028/101] selftests: mptcp: join: cannot rm sf if closed Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 029/101] drm/amdgpu: Fix uninitialized variable warning in amdgpu_afmt_acr Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 030/101] drm/amd/display: Assign linear_pitch_alignment even for VM Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 031/101] drm/amdgpu: fix overflowed array index read warning Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 032/101] drm/amdgpu/pm: Check the return value of smum_send_msg_to_smc Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 033/101] drm/amd/pm: fix uninitialized variable warning Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 034/101] drm/amd/pm: fix uninitialized variable warning for smu8_hwmgr Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 035/101] drm/amd/pm: fix warning using uninitialized value of max_vid_step Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 036/101] drm/amd/pm: Fix negative array index read Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 037/101] drm/amd/pm: fix the Out-of-bounds read warning Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 038/101] drm/amd/pm: fix uninitialized variable warnings for vega10_hwmgr Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 039/101] drm/amdgpu: avoid reading vf2pf info size from FB Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 040/101] drm/amd/display: Check gpio_id before used as array index Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 041/101] drm/amd/display: Stop amdgpu_dm initialize when stream nums greater than 6 Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 042/101] drm/amd/display: Add array index check for hdcp ddc access Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 043/101] drm/amd/display: Check num_valid_sets before accessing reader_wm_sets[] Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 044/101] drm/amd/display: Check msg_id before processing transcation Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 045/101] drm/amd/display: Fix Coverity INTEGER_OVERFLOW within dal_gpio_service_create Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 046/101] drm/amd/display: Spinlock before reading event Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 047/101] drm/amd/display: Ensure index calculation will not overflow Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 048/101] drm/amd/display: Skip inactive planes within ModeSupportAndSystemConfiguration Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 049/101] drm/amd/amdgpu: Check tbo resource pointer Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 050/101] drm/amd/pm: fix uninitialized variable warnings for vangogh_ppt Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 051/101] drm/amdgpu/pm: Fix uninitialized variable warning for smu10 Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 052/101] drm/amdgpu/pm: Fix uninitialized variable agc_btc_response Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 053/101] drm/amdgpu: Fix out-of-bounds write warning Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 054/101] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 055/101] drm/amdgpu: fix ucode out-of-bounds read warning Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 056/101] drm/amdgpu: fix mc_data " Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 057/101] drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 058/101] apparmor: fix possible NULL pointer dereference Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 059/101] wifi: ath11k: initialize ret in ath11k_qmi_load_file_target_mem() Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 060/101] drm/amdgpu/pm: Check input value for CUSTOM profile mode setting on legacy SOCs Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 061/101] drm/amdgpu: fix dereference after null check Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 062/101] drm/amdgpu: fix the waring dereferencing hive Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 063/101] drm/amd/pm: check specific index for aldebaran Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 064/101] drm/amdgpu: the warning dereferencing obj for nbio_v7_4 Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 065/101] drm/amd/pm: check negtive return for table entries Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 066/101] wifi: rtw89: ser: avoid multiple deinit on same CAM Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 067/101] drm/amdgpu: update type of buf size to u32 for eeprom functions Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 068/101] wifi: iwlwifi: remove fw_running op Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 069/101] cpufreq: scmi: Avoid overflow of target_freq in fast switch Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 070/101] PCI: al: Check IORESOURCE_BUS existence during probe Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 071/101] hwspinlock: Introduce hwspin_lock_bust() Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 072/101] RDMA/efa: Properly handle unexpected AQ completions Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 073/101] ionic: fix potential irq name truncation Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 074/101] pwm: xilinx: Fix u32 overflow issue in 32-bit width PWM mode Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 075/101] rcu/nocb: Remove buggy bypass lock contention mitigation Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 076/101] usbip: Dont submit special requests twice Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 077/101] usb: typec: ucsi: Fix null pointer dereference in trace Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 078/101] fsnotify: clear PARENT_WATCHED flags lazily Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 079/101] regmap: spi: Fix potential off-by-one when calculating reserved size Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 080/101] smack: tcp: ipv4, fix incorrect labeling Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 081/101] net/mlx5e: SHAMPO, Fix incorrect page release Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 082/101] drm/meson: plane: Add error handling Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 083/101] drm/bridge: tc358767: Check if fully initialized before signalling HPD event via IRQ Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 084/101] dmaengine: altera-msgdma: use irq variant of spin_lock/unlock while invoking callbacks Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 085/101] dmaengine: altera-msgdma: properly free descriptor in msgdma_free_descriptor Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 086/101] hwmon: (k10temp) Check return value of amd_smn_read() Greg Kroah-Hartman
2024-09-05 9:41 ` [PATCH 6.1 087/101] wifi: cfg80211: make hash table duplicates more survivable Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 088/101] driver: iio: add missing checks on iio_infos callback access Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 089/101] block: remove the blk_flush_integrity call in blk_integrity_unregister Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 090/101] drm/amd/display: added NULL check at start of dc_validate_stream Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 091/101] drm/amd/display: Correct the defined value for AMDGPU_DMUB_NOTIFICATION_MAX Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 092/101] drm/amd/display: Skip wbscl_set_scaler_filter if filter is null Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 093/101] media: uvcvideo: Enforce alignment of frame and interval Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 094/101] virtio_net: Fix napi_skb_cache_put warning Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 095/101] Bluetooth: SCO: Fix possible circular locking dependency on sco_connect_cfm Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 096/101] Bluetooth: SCO: fix sco_conn related locking and validity issues Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 097/101] ext4: fix inode tree inconsistency caused by ENOMEM Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 098/101] udf: Limit file size to 4TB Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 099/101] ext4: reject casefold inode flag without casefold feature Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 100/101] ext4: handle redirtying in ext4_bio_write_page() Greg Kroah-Hartman
2024-09-05 9:42 ` [PATCH 6.1 101/101] i2c: Use IS_REACHABLE() for substituting empty ACPI functions Greg Kroah-Hartman
2024-09-05 13:51 ` [PATCH 6.1 000/101] 6.1.109-rc1 review Pavel Machek
2024-09-05 14:18 ` Mark Brown
2024-09-05 21:08 ` Florian Fainelli
2024-09-06 0:25 ` Shuah Khan
2024-09-06 6:44 ` Naresh Kamboju
2024-09-06 10:02 ` Jon Hunter
2024-09-06 11:43 ` Peter Schneider
2024-09-06 22:32 ` Ron Economos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240905093716.330629304@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=ovs@meta.com \
--cc=patches@lists.linux.dev \
--cc=riel@surriel.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.