Skip to contentSkip to conversation

net: add sanity check in proto_register()

PATCH Applied Eric Dumazet 2 participants 2 messages Feb 16, 2022 – Feb 18, 2022

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

PATCH 1/1 net: add sanity check in proto_register()

From: Eric Dumazet <[email protected]>

prot->memory_allocated should only be set if prot->sysctl_mem is also set.

This is a followup of commit 25206111512d ("crypto: af_alg - get rid of alg_memory_allocated").

---
 net/core/sock.c | 4 ++++
 1 file changed, 4 insertions(+)
net/core/sock.c +4 -0
index 09d31a7dc68f88af42f75f3f445818fe273b04fb..d76218ab4999922879401262ba873b62aff943a0 100644
@@ -3718,6 +3718,10 @@ int proto_register(struct proto *prot, int alloc_slab)
 {
 	int ret = -ENOBUFS;
 
+	if (prot->memory_allocated && !prot->sysctl_mem) {
+		pr_err("%s: missing sysctl_mem\n", prot->name);
+		return -EINVAL;
+	}
 	if (alloc_slab) {
 		prot->slab = kmem_cache_create_usercopy(prot->name,
 					prot->obj_size, 0,
Signature · 1 line
2.35.1.265.g69c8d7142f-goog
#1 lore raw
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Wed, 16 Feb 2022 09:18:01 -0800 you wrote:

From: Eric Dumazet <[email protected]>

prot->memory_allocated should only be set if prot->sysctl_mem is also set.

This is a followup of commit 25206111512d ("crypto: af_alg - get rid of alg_memory_allocated").

[...]

Here is the summary with links:
- [net-next] net: add sanity check in proto_register()

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

You are awesome, thank you!

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