net-sysfs: initialize uid and gid before calling net_ns_get_ownership
authorXin Long <lucien.xin@gmail.com>
Mon, 25 Oct 2021 06:31:48 +0000 (02:31 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Nov 2021 18:48:22 +0000 (19:48 +0100)
commitaed897e96b191b56109bac700bf3555113e75ea1
tree7680371c9686c8b08a4b1cfb412226d0e4ab2e63
parentb0a2cd38553c77928ef1646ed1518486b1e70ae8
net-sysfs: initialize uid and gid before calling net_ns_get_ownership

commit f7a1e76d0f608961cc2fc681f867a834f2746bce upstream.

Currently in net_ns_get_ownership() it may not be able to set uid or gid
if make_kuid or make_kgid returns an invalid value, and an uninit-value
issue can be triggered by this.

This patch is to fix it by initializing the uid and gid before calling
net_ns_get_ownership(), as it does in kobject_get_ownership()

Fixes: e6dee9f3893c ("net-sysfs: add netdev_change_owner()")
Reported-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/net-sysfs.c