diff options
author | Eric Dumazet <edumazet@google.com> | 2022-02-16 20:18:01 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-02-18 07:06:06 +0300 |
commit | f20cfd662a62dc62c25d9feff29eadc600455ca7 (patch) | |
tree | 431a43a57d9c61e6b9a2ab66ba62c7a99fd4dcba /net | |
parent | 60f8ad2392d03d250f6d381e382f7c838cd5ec11 (diff) | |
download | linux-f20cfd662a62dc62c25d9feff29eadc600455ca7.tar.xz |
net: add sanity check in proto_register()
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").
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20220216171801.3604366-1-eric.dumazet@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 09d31a7dc68f..d76218ab4999 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, |