Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2] pds_core: quiesce DMA before freeing resources
@ 2026-06-04 21:36 Nikhil P. Rao
  2026-06-09  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Nikhil P. Rao @ 2026-06-04 21:36 UTC (permalink / raw)
  To: netdev
  Cc: kuba, brett.creeley, eric.joyner, andrew+netdev, davem, edumazet,
	pabeni, aleksander.lobakin, Nikhil P. Rao

pdsc_teardown() frees DMA buffers but does not disable bus mastering,
leaving the device able to perform DMA after the buffers are freed.
This can lead to use-after-free if the device writes to freed memory.

Add pci_clear_master() to pdsc_teardown() to disable bus mastering
before freeing resources, ensuring all DMA is quiesced.

Add pci_set_master() to pdsc_setup() to re-enable bus mastering,
which is needed for the firmware recovery path since pdsc_teardown()
now disables it.

Fixes: 01ba61b55b20 ("pds_core: Add adminq processing and commands")
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
---
v2:
- Move pci_clear_master() from pdsc_stop() to pdsc_teardown() to cover
  error paths (Sashiko)
- Add pci_set_master() to pdsc_setup() instead of pdsc_start() for
  recovery path (Sashiko)
- Drop Reviewed-by since patch changed substantially
v1: https://lore.kernel.org/netdev/20260603035245.32972-1-nikhil.rao@amd.com/
Sashiko review: https://sashiko.dev/#/patchset/20260603035245.32972-1-nikhil.rao%40amd.com

 drivers/net/ethernet/amd/pds_core/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
index 705cab7b0727..38a2446571af 100644
--- a/drivers/net/ethernet/amd/pds_core/core.c
+++ b/drivers/net/ethernet/amd/pds_core/core.c
@@ -446,6 +446,8 @@ int pdsc_setup(struct pdsc *pdsc, bool init)
 {
 	int err;
 
+	pci_set_master(pdsc->pdev);
+
 	err = pdsc_dev_init(pdsc);
 	if (err)
 		return err;
@@ -480,6 +482,8 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing)
 	if (pdsc->adminqcq.work.func)
 		cancel_work_sync(&pdsc->adminqcq.work);
 
+	pci_clear_master(pdsc->pdev);
+
 	pdsc_core_uninit(pdsc);
 
 	if (removing) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net v2] pds_core: quiesce DMA before freeing resources
  2026-06-04 21:36 [PATCH net v2] pds_core: quiesce DMA before freeing resources Nikhil P. Rao
@ 2026-06-09  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-09  0:30 UTC (permalink / raw)
  To: Nikhil P. Rao
  Cc: netdev, kuba, brett.creeley, eric.joyner, andrew+netdev, davem,
	edumazet, pabeni, aleksander.lobakin

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 4 Jun 2026 21:36:37 +0000 you wrote:
> pdsc_teardown() frees DMA buffers but does not disable bus mastering,
> leaving the device able to perform DMA after the buffers are freed.
> This can lead to use-after-free if the device writes to freed memory.
> 
> Add pci_clear_master() to pdsc_teardown() to disable bus mastering
> before freeing resources, ensuring all DMA is quiesced.
> 
> [...]

Here is the summary with links:
  - [net,v2] pds_core: quiesce DMA before freeing resources
    https://git.kernel.org/netdev/net-next/c/6443f4f20bda

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-09  0:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 21:36 [PATCH net v2] pds_core: quiesce DMA before freeing resources Nikhil P. Rao
2026-06-09  0:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox