Skip to contentSkip to conversation

af_unix: fix unix_sysctl_register() error path

PATCH Applied Eric Dumazet 3 participants 4 messages Jul 8, 2022 – Jul 9, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 af_unix: fix unix_sysctl_register() error path

We want to kfree(table) if @table has been kmalloced, ie for non initial network namespace.

Fixes 849d5aa3a1d8 ("af_unix: Do not call kmemdup() for init_net's sysctl table.")
Cc Kuniyuki Iwashima <[email protected]>
Cc Eric W. Biederman <[email protected]>
---
 net/unix/sysctl_net_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/sysctl_net_unix.c +1 -1
index 3f1fdffd6092c6d06d4f530d813ffcc1b02f3ee4..500129aa710c73537cde5208a48e75842259ee04 100644
@@ -43,7 +43,7 @@ int __net_init unix_sysctl_register(struct net *net)
 	return 0;
 
 err_reg:
-	if (net_eq(net, &init_net))
+	if (!net_eq(net, &init_net))
 		kfree(table);
 err_alloc:
 	return -ENOMEM;
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog
#1 lore raw
Quoted 9 lines · Eric Dumazet

We want to kfree(table) if @table has been kmalloced, ie for non initial network namespace.

Fixes 849d5aa3a1d8 ("af_unix: Do not call kmemdup() for init_net's sysctl table.")
Cc Kuniyuki Iwashima <[email protected]>
Cc Eric W. Biederman <[email protected]>

---

Wrong tag in [PATCH net], this patch is for net-next tree.

#2 lore raw

PATCH 1/1 af_unix: fix unix_sysctl_register() error path

In reply to Eric Dumazet
From:   Eric Dumazet <[email protected]>
Date:   Fri,  8 Jul 2022 16:28:58 +0000
Quoted 5 lines

We want to kfree(table) if @table has been kmalloced, ie for non initial network namespace.

Fixes 849d5aa3a1d8 ("af_unix: Do not call kmemdup() for init_net's sysctl table.")

Sorry for my carelessness and thank you for the fix!

Best regards,
Kuniyuki

#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 9 lines · On Fri, 8 Jul 2022 16:28:58 +0000 you wrote:

We want to kfree(table) if @table has been kmalloced, ie for non initial network namespace.

Fixes 849d5aa3a1d8 ("af_unix: Do not call kmemdup() for init_net's sysctl table.")
Cc Kuniyuki Iwashima <[email protected]>
Cc Eric W. Biederman <[email protected]>

[...]

Here is the summary with links:
- [net] af_unix: fix unix_sysctl_register() error path

    https://git.kernel.org/netdev/net-next/c/44ac441a51a7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html