net: don't try to ops lock uninitialized devs
authorJakub Kicinski <kuba@kernel.org>
Tue, 15 Apr 2025 15:15:52 +0000 (08:15 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 17 Apr 2025 01:28:11 +0000 (18:28 -0700)
commit4798cfa2097f0833d54d8f5ce20ef14631917839
treec731ce67262b4d0d26934feac33f9d7ef583f58a
parent2a5970d5aaff8f3e33ce3bfaa403ae88c40de40d
net: don't try to ops lock uninitialized devs

We need to be careful when operating on dev while in rtnl_create_link().
Some devices (vxlan) initialize netdev_ops in ->newlink, so later on.
Avoid using netdev_lock_ops(), the device isn't registered so we
cannot legally call its ops or generate any notifications for it.

netdev_ops_assert_locked_or_invisible() is safe to use, it checks
registration status first.

Reported-by: syzbot+de1c7d68a10e3f123bdd@syzkaller.appspotmail.com
Fixes: 04efcee6ef8d ("net: hold instance lock during NETDEV_CHANGE")
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250415151552.768373-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.c
net/core/rtnetlink.c