netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net-sysfs: initialize uid and gid before calling net_ns_get_ownership
@ 2021-10-25  6:31 Xin Long
  2021-10-25  8:46 ` Christian Brauner
  2021-10-25 15:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Xin Long @ 2021-10-25  6:31 UTC (permalink / raw)
  To: network dev; +Cc: davem, kuba, Paolo Abeni, Christian Brauner

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>
---
 net/core/net-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index f6197774048b..b2e49eb7001d 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1973,9 +1973,9 @@ int netdev_register_kobject(struct net_device *ndev)
 int netdev_change_owner(struct net_device *ndev, const struct net *net_old,
 			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;
-	kuid_t old_uid, new_uid;
-	kgid_t old_gid, new_gid;
 	int error;
 
 	net_ns_get_ownership(net_old, &old_uid, &old_gid);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net-sysfs: initialize uid and gid before calling net_ns_get_ownership
  2021-10-25  6:31 [PATCH net] net-sysfs: initialize uid and gid before calling net_ns_get_ownership Xin Long
@ 2021-10-25  8:46 ` Christian Brauner
  2021-10-25 15:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2021-10-25  8:46 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, davem, kuba, Paolo Abeni

On Mon, Oct 25, 2021 at 02:31:48AM -0400, Xin Long wrote:
> 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>
> ---

Looks good,
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net-sysfs: initialize uid and gid before calling net_ns_get_ownership
  2021-10-25  6:31 [PATCH net] net-sysfs: initialize uid and gid before calling net_ns_get_ownership Xin Long
  2021-10-25  8:46 ` Christian Brauner
@ 2021-10-25 15:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-25 15:20 UTC (permalink / raw)
  To: Xin Long; +Cc: netdev, davem, kuba, pabeni, christian.brauner

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 25 Oct 2021 02:31:48 -0400 you wrote:
> 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()
> 
> [...]

Here is the summary with links:
  - [net] net-sysfs: initialize uid and gid before calling net_ns_get_ownership
    https://git.kernel.org/netdev/net/c/f7a1e76d0f60

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-25 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-25  6:31 [PATCH net] net-sysfs: initialize uid and gid before calling net_ns_get_ownership Xin Long
2021-10-25  8:46 ` Christian Brauner
2021-10-25 15:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).