Commit 95920c2
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: 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>1 parent 521405c commit 95920c2
2 files changed
+66
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4159 | 4159 | | |
4160 | 4160 | | |
4161 | 4161 | | |
4162 | | - | |
4163 | | - | |
4164 | | - | |
| 4162 | + | |
| 4163 | + | |
4165 | 4164 | | |
4166 | | - | |
4167 | | - | |
4168 | | - | |
4169 | | - | |
| 4165 | + | |
| 4166 | + | |
| 4167 | + | |
| 4168 | + | |
4170 | 4169 | | |
4171 | 4170 | | |
4172 | 4171 | | |
| |||
4175 | 4174 | | |
4176 | 4175 | | |
4177 | 4176 | | |
4178 | | - | |
4179 | | - | |
| 4177 | + | |
| 4178 | + | |
| 4179 | + | |
| 4180 | + | |
| 4181 | + | |
| 4182 | + | |
| 4183 | + | |
4180 | 4184 | | |
4181 | 4185 | | |
4182 | 4186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
468 | 468 | | |
469 | 469 | | |
470 | 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 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
471 | 521 | | |
472 | 522 | | |
473 | 523 | | |
474 | 524 | | |
475 | | - | |
476 | 525 | | |
477 | 526 | | |
478 | 527 | | |
| |||
491 | 540 | | |
492 | 541 | | |
493 | 542 | | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
| 543 | + | |
| 544 | + | |
502 | 545 | | |
503 | | - | |
504 | 546 | | |
505 | | - | |
506 | 547 | | |
507 | 548 | | |
508 | 549 | | |
| |||
680 | 721 | | |
681 | 722 | | |
682 | 723 | | |
683 | | - | |
684 | | - | |
685 | 724 | | |
686 | 725 | | |
687 | 726 | | |
| |||
690 | 729 | | |
691 | 730 | | |
692 | 731 | | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
| 732 | + | |
702 | 733 | | |
703 | 734 | | |
704 | 735 | | |
| |||
708 | 739 | | |
709 | 740 | | |
710 | 741 | | |
711 | | - | |
712 | 742 | | |
713 | 743 | | |
714 | 744 | | |
| |||
0 commit comments