ipv4: correctly iterate over the target netns in inet_dump_ifaddr()
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Tue, 28 May 2024 20:30:30 +0000 (22:30 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 May 2024 01:43:42 +0000 (18:43 -0700)
A recent change to inet_dump_ifaddr had the function incorrectly iterate
over net rather than tgt_net, resulting in the data coming for the
incorrect network namespace.

Fixes: cdb2f80f1c10 ("inet: use xa_array iterator to implement inet_dump_ifaddr()")
Reported-by: Stéphane Graber <stgraber@stgraber.org>
Closes: https://github.com/lxc/incus/issues/892
Bisected-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Tested-by: Stéphane Graber <stgraber@stgraber.org>
Acked-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240528203030.10839-1-aleksandr.mikhalitsyn@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/devinet.c

index e827da128c5f5504c78bfdd389732ccbfd718147..f3892ee9dfb33f8af86e9deb450da41d1508b80c 100644 (file)
@@ -1903,7 +1903,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
 
        cb->seq = inet_base_seq(tgt_net);
 
-       for_each_netdev_dump(net, dev, ctx->ifindex) {
+       for_each_netdev_dump(tgt_net, dev, ctx->ifindex) {
                in_dev = __in_dev_get_rcu(dev);
                if (!in_dev)
                        continue;