]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
loopback: fix lockdep splat
authorMahesh Bandewar <maheshb@google.com>
Wed, 3 Jul 2019 06:16:31 +0000 (23:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 3 Jul 2019 18:24:38 +0000 (11:24 -0700)
dev_init_scheduler() and dev_activate() expect the caller to
hold RTNL. Since we don't want blackhole device to be initialized
per ns, we are initializing at init.

[    3.855027] Call Trace:
[    3.855034]  dump_stack+0x67/0x95
[    3.855037]  lockdep_rcu_suspicious+0xd5/0x110
[    3.855044]  dev_init_scheduler+0xe3/0x120
[    3.855048]  ? net_olddevs_init+0x60/0x60
[    3.855050]  blackhole_netdev_init+0x45/0x6e
[    3.855052]  do_one_initcall+0x6c/0x2fa
[    3.855058]  ? rcu_read_lock_sched_held+0x8c/0xa0
[    3.855066]  kernel_init_freeable+0x1e5/0x288
[    3.855071]  ? rest_init+0x260/0x260
[    3.855074]  kernel_init+0xf/0x180
[    3.855076]  ? rest_init+0x260/0x260
[    3.855078]  ret_from_fork+0x24/0x30

Fixes: 4de83b88c66 ("loopback: create blackhole net device similar to loopack.")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/loopback.c

index 3b39def5471e037418410f6fdcdf83d4b279b3da..14545a8797a8a2c9b61abc96cbdb1a3542481745 100644 (file)
@@ -261,8 +261,10 @@ static int __init blackhole_netdev_init(void)
        if (!blackhole_netdev)
                return -ENOMEM;
 
+       rtnl_lock();
        dev_init_scheduler(blackhole_netdev);
        dev_activate(blackhole_netdev);
+       rtnl_unlock();
 
        blackhole_netdev->flags |= IFF_UP | IFF_RUNNING;
        dev_net_set(blackhole_netdev, &init_net);