Skip to content

Commit f7a1e76

Browse files
lxindavem330
authored andcommitted
net-sysfs: initialize uid and gid before calling net_ns_get_ownership
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: e6dee9f ("net-sysfs: add netdev_change_owner()") Reported-by: Paolo Abeni <[email protected]> Signed-off-by: Xin Long <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 042b204 commit f7a1e76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/core/net-sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,9 +1973,9 @@ int netdev_register_kobject(struct net_device *ndev)
19731973
int netdev_change_owner(struct net_device *ndev, const struct net *net_old,
19741974
const struct net *net_new)
19751975
{
1976+
kuid_t old_uid = GLOBAL_ROOT_UID, new_uid = GLOBAL_ROOT_UID;
1977+
kgid_t old_gid = GLOBAL_ROOT_GID, new_gid = GLOBAL_ROOT_GID;
19761978
struct device *dev = &ndev->dev;
1977-
kuid_t old_uid, new_uid;
1978-
kgid_t old_gid, new_gid;
19791979
int error;
19801980

19811981
net_ns_get_ownership(net_old, &old_uid, &old_gid);

0 commit comments

Comments
 (0)