From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Simon Horman <horms@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Mina Almasry <almasrymina@google.com>,
Yonglong Liu <liuyonglong@huawei.com>,
Yunsheng Lin <linyunsheng@huawei.com>,
Pavel Begunkov <asml.silence@gmail.com>,
Matthew Wilcox <willy@infradead.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-mm@kvack.org,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Qiuling Ren" <qren@redhat.com>, "Yuying Ma" <yuma@redhat.com>
Subject: [PATCH net-next v8 0/2] Fix late DMA unmap crash for page pool
Date: Mon, 07 Apr 2025 18:53:27 +0200 [thread overview]
Message-ID: <20250407-page-pool-track-dma-v8-0-da9500d4ba21@redhat.com> (raw)
This series fixes the late dma_unmap crash for page pool first reported
by Yonglong Liu in [0]. It is an alternative approach to the one
submitted by Yunsheng Lin, most recently in [1]. The first commit just
wraps some tests in a helper function, in preparation of the main change
in patch 2. See the commit message of patch 2 for the details.
-Toke
[0] https://lore.kernel.org/lkml/8067f204-1380-4d37-8ffd-007fc6f26738@kernel.org/T/
[1] https://lore.kernel.org/r/20250307092356.638242-1-linyunsheng@huawei.com
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
Changes in v8:
- Move defines to mm.h
- Keep pp->dma_sync as 1-bit wide
- Unset pp->dma_addr on id alloc failure
- Rebase on -rc1
- Link to v7: https://lore.kernel.org/r/20250404-page-pool-track-dma-v7-0-ad34f069bc18@redhat.com
Changes in v7:
- Change WARN_ON logic if xarray alloc fails
- Don't leak xarray ID if page_pool_set_dma_addr_netmem() fails
- Unconditionally init xarray in page_pool_init()
- Rebase on current net-next
- Link to v6: https://lore.kernel.org/r/20250401-page-pool-track-dma-v6-0-8b83474870d4@redhat.com
Changes in v6:
- Add READ_ONCE() around both reads of pp->dma_sync
- Link to v5: https://lore.kernel.org/r/20250328-page-pool-track-dma-v5-0-55002af683ad@redhat.com
Changes in v5:
- Dereferencing pp->p.dev if pp->pma_sync is unset could lead to a
crash, so make sure we don't do that.
- With the change above, patch 2 was just changing a single field, so
squash it into patch 3
- Link to v4: https://lore.kernel.org/r/20250327-page-pool-track-dma-v4-0-b380dc6706d0@redhat.com
Changes in v4:
- Rebase on net-next
- Collect tags
- Link to v3: https://lore.kernel.org/r/20250326-page-pool-track-dma-v3-0-8e464016e0ac@redhat.com
Changes in v3:
- Use a full-width bool for pp->dma_sync instead of a full unsigned
long (in patch 2), and leave pp->dma_sync_cpu alone.
- Link to v2: https://lore.kernel.org/r/20250325-page-pool-track-dma-v2-0-113ebc1946f3@redhat.com
Changes in v2:
- Always leave two bits at the top of pp_magic as zero, instead of one
- Add an rcu_read_lock() around __page_pool_dma_sync_for_device()
- Add a comment in poison.h with a reference to the bitmask definition
- Add a longer description of the logic of the bitmask definitions to
the comment in types.h, and a summary of the security implications of
using the pp_magic field to the commit message of patch 3
- Collect Mina's Reviewed-by and Yonglong's Tested-by tags
- Link to v1: https://lore.kernel.org/r/20250314-page-pool-track-dma-v1-0-c212e57a74c2@redhat.com
---
Toke Høiland-Jørgensen (2):
page_pool: Move pp_magic check into helper functions
page_pool: Track DMA-mapped pages and unmap them when destroying the pool
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 4 +-
include/linux/mm.h | 59 +++++++++++++++++
include/linux/poison.h | 4 ++
include/net/page_pool/types.h | 7 ++
mm/page_alloc.c | 8 +--
net/core/netmem_priv.h | 33 +++++++++-
net/core/page_pool.c | 81 ++++++++++++++++++++----
net/core/skbuff.c | 16 +----
net/core/xdp.c | 4 +-
9 files changed, 178 insertions(+), 38 deletions(-)
---
base-commit: 61f96e684edd28ca40555ec49ea1555df31ba619
change-id: 20250310-page-pool-track-dma-0332343a460e
next reply other threads:[~2025-04-07 16:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 16:53 Toke Høiland-Jørgensen [this message]
2025-04-07 16:53 ` [PATCH net-next v8 1/2] page_pool: Move pp_magic check into helper functions Toke Høiland-Jørgensen
2025-04-08 19:13 ` Jakub Kicinski
2025-04-09 10:36 ` Toke Høiland-Jørgensen
2025-04-07 16:53 ` [PATCH net-next v8 2/2] page_pool: Track DMA-mapped pages and unmap them when destroying the pool Toke Høiland-Jørgensen
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=20250407-page-pool-track-dma-v8-0-da9500d4ba21@redhat.com \
--to=toke@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=asml.silence@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linyunsheng@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qren@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=willy@infradead.org \
--cc=yuma@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).