From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Thomas Weissschuh <thomas.weissschuh@linutronix.de>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Sasha Levin <sashal@kernel.org>,
linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-5.10] ARM: 9467/1: mm: Don't use %pK through printk
Date: Mon, 23 Feb 2026 07:37:17 -0500 [thread overview]
Message-ID: <20260223123738.1532940-12-sashal@kernel.org> (raw)
In-Reply-To: <20260223123738.1532940-1-sashal@kernel.org>
From: Thomas Weissschuh <thomas.weissschuh@linutronix.de>
[ Upstream commit 012ea376a5948b025f260aa45d2a6ec5d96674ea ]
Restricted pointers ("%pK") were never meant to be used
through printk(). They can acquire sleeping locks in atomic contexts.
Switch to %px over the more secure %p as this usage is a debugging aid,
gated behind CONFIG_DEBUG_VIRTUAL and used by WARN().
Link: https://lore.kernel.org/lkml/20250113171731-dc10e3c1-da64-4af0-b767-7c7070468023@linutronix.de/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a thorough analysis.
## Analysis
### 1. Commit Message Analysis
The commit fixes a misuse of the `%pK` format specifier in a `WARN()`
macro within `arch/arm/mm/physaddr.c`. The `%pK` format was designed for
use in procfs/sysfs/debugfs seq_file handlers, **not** through
`printk()` or `WARN()`. When used through `printk()`, `%pK` can acquire
sleeping locks (particularly with LSMs that use sleeping spinlocks),
which is invalid when called from atomic contexts.
### 2. Code Change Analysis
The change is a single-character substitution in one format string:
- `%pK` → `%px` in a `WARN()` call inside `__virt_to_phys()`
The `WARN()` macro internally uses `printk()`. The `%pK` format
specifier can invoke security module hooks that acquire sleeping locks.
Since `WARN()` can fire from any context (including atomic, interrupt,
or with spinlocks held), this creates a **sleeping-in-atomic-context
bug**.
The choice of `%px` (raw pointer) over `%p` (hashed pointer) is
deliberate: this code is gated behind `CONFIG_DEBUG_VIRTUAL` and is a
debugging aid, so showing the actual address is appropriate.
### 3. Bug Classification
This is a **real bug fix**: sleeping-in-atomic-context. On `PREEMPT_RT`
kernels (increasingly common), this is a hard failure. On non-RT
kernels, it can cause lockdep splats and potential hangs. The bug is
triggered whenever `__virt_to_phys()` is called with an invalid address
while the caller holds a spinlock or is in interrupt context.
### 4. Scope and Risk Assessment
- **1 file changed, 1 line modified** - Extremely minimal scope
- **Zero risk of regression** - Only changes the format of a debug
message
- **Self-contained** - No dependencies on other commits
- **Part of a systematic kernel-wide effort** - Similar fixes applied to
arm64, riscv, MIPS, powerpc, bpf, networking, drm, etc.
### 5. User Impact
- Affects all ARM users with `CONFIG_DEBUG_VIRTUAL` enabled
- On PREEMPT_RT kernels: can cause invalid wait context warnings or
actual hangs
- On regular kernels: can cause lockdep warnings
- The affected file has existed since v4.11 (commit e377cd8221ebb,
January 2017), so all stable trees have this code
### 6. Stable Kernel Rules Check
- **Obviously correct**: Yes - single format specifier change, well-
understood issue
- **Fixes a real bug**: Yes - sleeping in atomic context
- **Small and contained**: Yes - 1 line change
- **No new features**: Correct - pure fix
- **Tested**: Yes - part of a systematic effort with identical fixes
across multiple subsystems
### Verification
- **Verified via `git show e377cd8221ebb`**: The affected file
`arch/arm/mm/physaddr.c` was introduced in v4.11 (commit from Jan
2017), confirming it exists in all active stable trees
- **Verified via `git log master --oneline --grep="Don't use %pK"`**: At
least 15+ similar commits across the kernel (arm64, riscv, MIPS,
powerpc, bpf, drm, networking, etc.) confirm this is a systematic,
well-understood issue
- **Verified via lore.kernel.org discussion**: Thomas Weißschuh's
original mail confirms `%pK` was "only ever meant to be used from
procfs/sysfs/debugfs handlers" and causes sleeping lock acquisition
through printk in atomic contexts, particularly problematic with
PREEMPT_RT
- **Verified via code read**: The `WARN()` macro is in
`__virt_to_phys()` which is called via `virt_to_phys()` from many
contexts, including potentially atomic contexts
- **Verified the fix is self-contained**: The change is a single format
specifier substitution with no dependencies
- **Could NOT verify**: Whether identical arm64/riscv fixes
(892d20acf36c3, eb8db421ce83f) were already backported to stable trees
- but each architecture's fix is independent
### Conclusion
This is a textbook stable backport candidate: a one-line fix for a real
sleeping-in-atomic-context bug, with zero regression risk, in code that
exists in all stable trees. The fix is part of a well-understood
systematic effort across the entire kernel.
**YES**
arch/arm/mm/physaddr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mm/physaddr.c b/arch/arm/mm/physaddr.c
index 3f263c840ebc4..1a37ebfacbba9 100644
--- a/arch/arm/mm/physaddr.c
+++ b/arch/arm/mm/physaddr.c
@@ -38,7 +38,7 @@ static inline bool __virt_addr_valid(unsigned long x)
phys_addr_t __virt_to_phys(unsigned long x)
{
WARN(!__virt_addr_valid(x),
- "virt_to_phys used for non-linear address: %pK (%pS)\n",
+ "virt_to_phys used for non-linear address: %px (%pS)\n",
(void *)x, (void *)x);
return __virt_to_phys_nodebug(x);
--
2.51.0
next prev parent reply other threads:[~2026-02-23 12:37 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 12:37 [PATCH AUTOSEL 6.19-6.1] drm/amd/display: Remove conditional for shaper 3DLUT power-on Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] ASoC: rt721-sdca: Fix issue of fail to detect OMTP jack type Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] ALSA: hda/tas2781: Ignore reset check for SPI device Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-5.15] btrfs: replace BUG() with error handling in __btrfs_balance() Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-5.15] ALSA: usb-audio: Add sanity check for OOB writes at silencing Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.12] drm/amd/display: Fix system resume lag issue Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.12] arm64: hugetlbpage: avoid unused-but-set-parameter warning (gcc-16) Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.12] drm/amd/display: Fix writeback on DCN 3.2+ Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] drm/amdgpu: Skip vcn poison irq release on VF Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] drm/amdgpu: return when ras table checksum is error Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] regulator: core: Remove regulator supply_name length limit Sasha Levin
2026-02-23 12:37 ` Sasha Levin [this message]
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-5.10] drm/radeon: Add HAINAN clock adjustment Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] drm/amdgpu: avoid sdma ring reset in sriov Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.12] spi: spidev: fix lock inversion between spi_lock and buf_lock Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-5.15] drm/amdgpu: Adjust usleep_range in fence wait Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19] mshv: Ignore second stats page map result failure Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19] btrfs: do not ASSERT() when the fs flips RO inside btrfs_repair_io_failure() Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] ALSA: hda/hdmi: Add quirk for TUXEDO IBS14G6 Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19] drm/amd/display: set enable_legacy_fast_update to false for DCN36 Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19] x86/hyperv: Move hv crash init after hypercall pg setup Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] mshv: clear eventfd counter on irqfd shutdown Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-5.10] drm/amd/display: Avoid updating surface with the same surface under MPO Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-5.15] ALSA: usb-audio: Update the number of packets properly at receiving Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.12] drm/amd/display: bypass post csc for additional color spaces in dal Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] ASoC: amd: amd_sdw: add machine driver quirk for Lenovo models Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-6.18] ALSA: hda/realtek: Fix headset mic on ASUS Zenbook 14 UX3405MA Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19] Drivers: hv: vmbus: Use kthread for vmbus interrupts on PREEMPT_RT Sasha Levin
2026-02-23 12:37 ` [PATCH AUTOSEL 6.19-5.10] drm/amdgpu: Add HAINAN clock adjustment Sasha Levin
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=20260223123738.1532940-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=patches@lists.linux.dev \
--cc=rmk+kernel@armlinux.org.uk \
--cc=stable@vger.kernel.org \
--cc=thomas.weissschuh@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox