diff options
author | David Howells <dhowells@redhat.com> | 2020-10-02 14:04:51 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-14 09:46:23 +0200 |
commit | e5e3293bd5a022b2c0d95123e753bd931f702f3f (patch) | |
tree | 4ef2134579129820caa870f7e2b92d644159a599 | |
parent | 74c09469251b97f0885db64c81c691f891e45c3f (diff) |
rxrpc: Fix server keyring leak
[ Upstream commit 38b1dc47a35ba14c3f4472138ea56d014c2d609b ]
If someone calls setsockopt() twice to set a server key keyring, the first
keyring is leaked.
Fix it to return an error instead if the server key keyring is already set.
Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | net/rxrpc/ar-key.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/rxrpc/ar-key.c b/net/rxrpc/ar-key.c index 20549c13eb13..ea615e53eab2 100644 --- a/net/rxrpc/ar-key.c +++ b/net/rxrpc/ar-key.c @@ -897,7 +897,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) _enter(""); - if (optlen <= 0 || optlen > PAGE_SIZE - 1) + if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities) return -EINVAL; description = kmalloc(optlen + 1, GFP_KERNEL); |