diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-07-31 10:11:58 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-08-01 15:01:29 -0700 |
commit | ceaac91dcd065db781d1ed5dfaef0686b8ec44dc (patch) | |
tree | 4eaf30a87763ea3be8b9ccf7b0d828806bc0c18e /net/core/dev.c | |
parent | 005c9600003eabcb22336f37e149eed08f0a946a (diff) |
net: make sure we never create ifindex = 0
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/
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20230731171159.988962-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 3 |
1 files changed, 1 insertions, 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); |