Message ID | 20220216171801.3604366-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | f20cfd662a62dc62c25d9feff29eadc600455ca7 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: add sanity check in proto_register() | expand |
Hello: This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <kuba@kernel.org>: On Wed, 16 Feb 2022 09:18:01 -0800 you wrote: > From: Eric Dumazet <edumazet@google.com> > > 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!
diff --git a/net/core/sock.c b/net/core/sock.c index 09d31a7dc68f88af42f75f3f445818fe273b04fb..d76218ab4999922879401262ba873b62aff943a0 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -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,