netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: make sure we never create ifindex = 0
@ 2023-07-31 17:11 Jakub Kicinski
  2023-08-01  6:07 ` Leon Romanovsky
  2023-08-01 22:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-07-31 17:11 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, Jakub Kicinski, Stephen Hemminger, leon

Instead of allocating from 1 use proper xa_init flag,
to protect ourselves from IDs wrapping back to 0.

Fixes: 759ab1edb56c ("net: store netdevs in an xarray")
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Link: https://lore.kernel.org/all/20230728162350.2a6d4979@hermes.local/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: leon@kernel.org
---
 net/core/dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index b58674774a57..10e5a036c706 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11271,8 +11271,7 @@ static int __net_init netdev_init(struct net *net)
 	if (net->dev_index_head == NULL)
 		goto err_idx;
 
-	net->ifindex = 1;
-	xa_init_flags(&net->dev_by_index, XA_FLAGS_ALLOC);
+	xa_init_flags(&net->dev_by_index, XA_FLAGS_ALLOC1);
 
 	RAW_INIT_NOTIFIER_HEAD(&net->netdev_chain);
 
-- 
2.41.0


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

* Re: [PATCH net-next v2] net: make sure we never create ifindex = 0
  2023-07-31 17:11 [PATCH net-next v2] net: make sure we never create ifindex = 0 Jakub Kicinski
@ 2023-08-01  6:07 ` Leon Romanovsky
  2023-08-01 22:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2023-08-01  6:07 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, Stephen Hemminger

On Mon, Jul 31, 2023 at 10:11:58AM -0700, Jakub Kicinski wrote:
> Instead of allocating from 1 use proper xa_init flag,
> to protect ourselves from IDs wrapping back to 0.
> 
> Fixes: 759ab1edb56c ("net: store netdevs in an xarray")
> Reported-by: Stephen Hemminger <stephen@networkplumber.org>
> Link: https://lore.kernel.org/all/20230728162350.2a6d4979@hermes.local/
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: leon@kernel.org
> ---
>  net/core/dev.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

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

* Re: [PATCH net-next v2] net: make sure we never create ifindex = 0
  2023-07-31 17:11 [PATCH net-next v2] net: make sure we never create ifindex = 0 Jakub Kicinski
  2023-08-01  6:07 ` Leon Romanovsky
@ 2023-08-01 22:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-01 22:10 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, stephen, leon

Hello:

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

On Mon, 31 Jul 2023 10:11:58 -0700 you wrote:
> Instead of allocating from 1 use proper xa_init flag,
> to protect ourselves from IDs wrapping back to 0.
> 
> Fixes: 759ab1edb56c ("net: store netdevs in an xarray")
> Reported-by: Stephen Hemminger <stephen@networkplumber.org>
> Link: https://lore.kernel.org/all/20230728162350.2a6d4979@hermes.local/
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: make sure we never create ifindex = 0
    https://git.kernel.org/netdev/net-next/c/ceaac91dcd06

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] 3+ messages in thread

end of thread, other threads:[~2023-08-01 22:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-31 17:11 [PATCH net-next v2] net: make sure we never create ifindex = 0 Jakub Kicinski
2023-08-01  6:07 ` Leon Romanovsky
2023-08-01 22:10 ` 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).