You need to sign in or sign up before continuing.
提交 7ecee385 编写于 作者: X Xin Long 提交者: Zheng Zengkai

net-sysfs: initialize uid and gid before calling net_ns_get_ownership

stable inclusion
from stable-5.10.77
commit aed897e96b191b56109bac700bf3555113e75ea1
bugzilla: 185677 https://gitee.com/openeuler/kernel/issues/I4IAP7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=aed897e96b191b56109bac700bf3555113e75ea1

--------------------------------

commit f7a1e76d 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: e6dee9f3 ("net-sysfs: add netdev_change_owner()")
Reported-by: NPaolo Abeni <pabeni@redhat.com>
Signed-off-by: NXin Long <lucien.xin@gmail.com>
Acked-by: NChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 64f394a6
...@@ -1957,9 +1957,9 @@ int netdev_register_kobject(struct net_device *ndev) ...@@ -1957,9 +1957,9 @@ int netdev_register_kobject(struct net_device *ndev)
int netdev_change_owner(struct net_device *ndev, const struct net *net_old, int netdev_change_owner(struct net_device *ndev, const struct net *net_old,
const struct net *net_new) const struct net *net_new)
{ {
kuid_t old_uid = GLOBAL_ROOT_UID, new_uid = GLOBAL_ROOT_UID;
kgid_t old_gid = GLOBAL_ROOT_GID, new_gid = GLOBAL_ROOT_GID;
struct device *dev = &ndev->dev; struct device *dev = &ndev->dev;
kuid_t old_uid, new_uid;
kgid_t old_gid, new_gid;
int error; int error;
net_ns_get_ownership(net_old, &old_uid, &old_gid); net_ns_get_ownership(net_old, &old_uid, &old_gid);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册