* [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint
@ 2025-03-18 3:24 Qingfang Deng
2025-03-18 23:08 ` Keller, Jacob E
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Qingfang Deng @ 2025-03-18 3:24 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Ong Boon Leong,
netdev, linux-stm32, linux-arm-kernel, linux-kernel
Cc: stable
The cpumask should not be a local variable, since its pointer is saved
to irq_desc and may be accessed from procfs.
To fix it, use the persistent mask cpumask_of(cpu#).
Cc: stable@vger.kernel.org
Fixes: 8deec94c6040 ("net: stmmac: set IRQ affinity hint for multi MSI vectors")
Signed-off-by: Qingfang Deng <dqfext@gmail.com>
---
v2: use cpumask_of()
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b22417167cac..ec63452187d0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3667,7 +3667,6 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
{
struct stmmac_priv *priv = netdev_priv(dev);
enum request_irq_err irq_err;
- cpumask_t cpu_mask;
int irq_idx = 0;
char *int_name;
int ret;
@@ -3796,9 +3795,8 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
irq_idx = i;
goto irq_error;
}
- cpumask_clear(&cpu_mask);
- cpumask_set_cpu(i % num_online_cpus(), &cpu_mask);
- irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask);
+ irq_set_affinity_hint(priv->rx_irq[i],
+ cpumask_of(i % num_online_cpus()));
}
/* Request Tx MSI irq */
@@ -3821,9 +3819,8 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
irq_idx = i;
goto irq_error;
}
- cpumask_clear(&cpu_mask);
- cpumask_set_cpu(i % num_online_cpus(), &cpu_mask);
- irq_set_affinity_hint(priv->tx_irq[i], &cpu_mask);
+ irq_set_affinity_hint(priv->tx_irq[i],
+ cpumask_of(i % num_online_cpus()));
}
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint
2025-03-18 3:24 [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint Qingfang Deng
@ 2025-03-18 23:08 ` Keller, Jacob E
2025-03-24 18:34 ` Jakub Kicinski
2025-03-24 18:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Keller, Jacob E @ 2025-03-18 23:08 UTC (permalink / raw)
To: Qingfang Deng, Andrew Lunn, David S. Miller, Dumazet, Eric,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Ong, Boon Leong, netdev@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
> -----Original Message-----
> From: Qingfang Deng <dqfext@gmail.com>
> Sent: Monday, March 17, 2025 8:24 PM
> To: Andrew Lunn <andrew+netdev@lunn.ch>; David S. Miller
> <davem@davemloft.net>; Dumazet, Eric <edumazet@google.com>; Jakub Kicinski
> <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; Alexandre Torgue
> <alexandre.torgue@foss.st.com>; Ong, Boon Leong
> <boon.leong.ong@intel.com>; netdev@vger.kernel.org; linux-stm32@st-md-
> mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> Subject: [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint
>
> The cpumask should not be a local variable, since its pointer is saved
> to irq_desc and may be accessed from procfs.
> To fix it, use the persistent mask cpumask_of(cpu#).
>
> Cc: stable@vger.kernel.org
> Fixes: 8deec94c6040 ("net: stmmac: set IRQ affinity hint for multi MSI vectors")
> Signed-off-by: Qingfang Deng <dqfext@gmail.com>
> ---
> v2: use cpumask_of()
>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint
2025-03-18 3:24 [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint Qingfang Deng
2025-03-18 23:08 ` Keller, Jacob E
@ 2025-03-24 18:34 ` Jakub Kicinski
2025-03-24 18:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2025-03-24 18:34 UTC (permalink / raw)
To: Qingfang Deng
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Maxime Coquelin, Alexandre Torgue, Ong Boon Leong, netdev,
linux-stm32, linux-arm-kernel, linux-kernel, stable
On Tue, 18 Mar 2025 11:24:23 +0800 Qingfang Deng wrote:
> - cpumask_clear(&cpu_mask);
> - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask);
> - irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask);
> + irq_set_affinity_hint(priv->rx_irq[i],
> + cpumask_of(i % num_online_cpus()));
This does fix the bug you're targeting, but FWIW num_online_cpus()
is not great in general. The online CPU mask can be sparse.
You may want to look into finding 'nth' online CPU instead of the naive
modulo as a follow up.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint
2025-03-18 3:24 [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint Qingfang Deng
2025-03-18 23:08 ` Keller, Jacob E
2025-03-24 18:34 ` Jakub Kicinski
@ 2025-03-24 18:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-24 18:50 UTC (permalink / raw)
To: Qingfang Deng
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
alexandre.torgue, boon.leong.ong, netdev, linux-stm32,
linux-arm-kernel, linux-kernel, stable
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 18 Mar 2025 11:24:23 +0800 you wrote:
> The cpumask should not be a local variable, since its pointer is saved
> to irq_desc and may be accessed from procfs.
> To fix it, use the persistent mask cpumask_of(cpu#).
>
> Cc: stable@vger.kernel.org
> Fixes: 8deec94c6040 ("net: stmmac: set IRQ affinity hint for multi MSI vectors")
> Signed-off-by: Qingfang Deng <dqfext@gmail.com>
>
> [...]
Here is the summary with links:
- [net,v2] net: stmmac: Fix accessing freed irq affinity_hint
https://git.kernel.org/netdev/net/c/c60d101a226f
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] 4+ messages in thread
end of thread, other threads:[~2025-03-24 18:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 3:24 [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint Qingfang Deng
2025-03-18 23:08 ` Keller, Jacob E
2025-03-24 18:34 ` Jakub Kicinski
2025-03-24 18:50 ` 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;
as well as URLs for NNTP newsgroup(s).