Commit 15b8a5b
page_pool: Fix PP_MAGIC_MASK to avoid crashing on some 32-bit arches
commit 95920c2 upstream.
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: ee62ce7 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 68a8fc3 commit 15b8a5b
2 files changed
+66
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4318 | 4318 | | |
4319 | 4319 | | |
4320 | 4320 | | |
4321 | | - | |
4322 | | - | |
4323 | | - | |
| 4321 | + | |
| 4322 | + | |
4324 | 4323 | | |
4325 | | - | |
4326 | | - | |
4327 | | - | |
4328 | | - | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
4329 | 4328 | | |
4330 | 4329 | | |
4331 | 4330 | | |
| |||
4334 | 4333 | | |
4335 | 4334 | | |
4336 | 4335 | | |
4337 | | - | |
4338 | | - | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
4339 | 4343 | | |
4340 | 4344 | | |
4341 | 4345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
465 | 515 | | |
466 | 516 | | |
467 | 517 | | |
468 | 518 | | |
469 | | - | |
470 | 519 | | |
471 | 520 | | |
472 | 521 | | |
| |||
485 | 534 | | |
486 | 535 | | |
487 | 536 | | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
| 537 | + | |
| 538 | + | |
496 | 539 | | |
497 | | - | |
498 | 540 | | |
499 | | - | |
500 | 541 | | |
501 | 542 | | |
502 | 543 | | |
| |||
669 | 710 | | |
670 | 711 | | |
671 | 712 | | |
672 | | - | |
673 | | - | |
674 | 713 | | |
675 | 714 | | |
676 | 715 | | |
| |||
679 | 718 | | |
680 | 719 | | |
681 | 720 | | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
| 721 | + | |
691 | 722 | | |
692 | 723 | | |
693 | 724 | | |
| |||
697 | 728 | | |
698 | 729 | | |
699 | 730 | | |
700 | | - | |
701 | 731 | | |
702 | 732 | | |
703 | 733 | | |
| |||
0 commit comments