linux/include
Toke Høiland-Jørgensen 95920c2ed0 page_pool: Fix PP_MAGIC_MASK to avoid crashing on some 32-bit arches
Helge reported that the introduction of PP_MAGIC_MASK let to crashes on
boot on his 32-bit parisc machine. The cause of this is the mask is set
too wide, so the page_pool_page_is_pp() incurs false positives which
crashes the machine.

Just disabling the check in page_pool_is_pp() will lead to the page_pool
code itself malfunctioning; so instead of doing this, this patch changes
the define for PP_DMA_INDEX_BITS to avoid mistaking arbitrary kernel
pointers for page_pool-tagged pages.

The fix relies on the kernel pointers that alias with the pp_magic field
always being above PAGE_OFFSET. With this assumption, we can use the
lowest bit of the value of PAGE_OFFSET as the upper bound of the
PP_DMA_INDEX_MASK, which should avoid the false positives.

Because we cannot rely on PAGE_OFFSET always being a compile-time
constant, nor on it always being >0, we fall back to disabling the
dma_index storage when there are not enough bits available. This leaves
us in the situation we were in before the patch in the Fixes tag, but
only on a subset of architecture configurations. This seems to be the
best we can do until the transition to page types in complete for
page_pool pages.

v2:
- Make sure there's at least 8 bits available and that the PAGE_OFFSET
  bit calculation doesn't wrap

Link: https://lore.kernel.org/all/aMNJMFa5fDalFmtn@p100/
Fixes: ee62ce7a1d ("page_pool: Track DMA-mapped pages and unmap them when destroying the pool")
Cc: stable@vger.kernel.org # 6.15+
Tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Tested-by: Helge Deller <deller@gmx.de>
Link: https://patch.msgid.link/20250930114331.675412-1-toke@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
History 2025-10-06 12:14:04 -07:00
..
acpi Merge branches 'acpi-scan', 'acpi-processor' and 'acpi-sysfs' 2025-09-29 15:12:52 +02:00
asm-generic Kbuild updates for 6.18 2025-10-01 20:58:51 -07:00
clocksource clocksource/drivers/arm_arch_timer_mmio: Switch over to standalone driver 2025-09-23 12:31:50 +02:00
crypto Optimize fsverity with 2-way interleaved hashing 2025-09-29 15:55:20 -07:00
cxl cxl/events: Trace Memory Sparing Event Record 2025-07-18 08:19:56 -07:00
drm amd-drm-next-6.18-2025-09-19: 2025-09-22 08:45:51 +10:00
dt-bindings Networking changes for 6.18. 2025-10-02 15:17:01 -07:00
hyperv hyperv-next for v6.16 2025-06-03 08:39:20 -07:00
keys rxrpc: Add YFS RxGK (GSSAPI) security class 2025-04-14 17:36:41 -07:00
kunit linux_kselftest-kunit-6.18-rc1 2025-10-01 19:15:11 -07:00
kvm KVM: arm64: vgic-v3: Erase LPIs from xarray outside of raw spinlocks 2025-09-10 02:56:20 -07:00
linux page_pool: Fix PP_MAGIC_MASK to avoid crashing on some 32-bit arches 2025-10-06 12:14:04 -07:00
math-emu
media media: v4l2-common: Add legacy camera sensor clock helper 2025-09-09 15:59:19 +02:00
memory memory: renesas-rpc-if: Add RZ/G3E xSPI support 2025-05-01 12:22:25 +02:00
misc cxl: Remove driver 2025-03-16 22:04:27 +11:00
net net: psp: don't assume reply skbs will have a socket 2025-10-03 10:23:50 -07:00
pcmcia pcmcia: remove PCCARD_IODYN 2025-08-16 15:37:47 +02:00
ras tracing, AER: Hide PCIe AER event when PCIEAER is not configured 2025-07-21 16:40:56 -04:00
rdma IB: Extend UVERBS_METHOD_REG_MR to get DMAH 2025-07-23 01:42:11 -04:00
rv kernel-6.18-rc1.clone3 2025-09-29 10:36:50 -07:00
scsi scsi: switch ->bios_param() to passing gendisk 2025-08-13 02:59:28 -04:00
soc ARM: soc updates for 6.18 2025-10-01 17:41:15 -07:00
sound ASoC: Updates for v6.18 round 2 2025-09-28 15:41:17 +02:00
target scsi: target: core: Constify enabled() in struct target_opcode_descriptor 2025-05-20 22:11:03 -04:00
trace Networking changes for 6.18. 2025-10-02 15:17:01 -07:00
uapi Networking changes for 6.18. 2025-10-02 15:17:01 -07:00
ufs Merge patch series "ufs: ufs-qcom: Align programming sequence as per HW spec" 2025-07-14 21:00:41 -04:00
vdso Updates for the VDSO subsystem: 2025-09-30 16:58:21 -07:00
video drm/vesadrm: Support DRM_FORMAT_C8 2025-08-26 09:54:20 +02:00
xen xen: replace XENFEAT_auto_translated_physmap with xen_pv_domain() 2025-09-08 17:01:36 +02:00
Kbuild drm: ensure drm headers are self-contained and pass kernel-doc 2025-02-12 10:44:43 +02:00