diff options
author | David Howells <dhowells@redhat.com> | 2020-10-02 16:04:51 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-14 10:51:14 +0300 |
commit | c36782a0c96d061e9b50153a05761dfc2aace648 (patch) | |
tree | f09c4964bdb6d08006ca7a70cb4717dfc05453af /net/rxrpc/key.c | |
parent | c11f690471759b1f0f0e26d0f4789f790bba3f6c (diff) | |
download | linux-c36782a0c96d061e9b50153a05761dfc2aace648.tar.xz |
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>
Diffstat (limited to 'net/rxrpc/key.c')
-rw-r--r-- | net/rxrpc/key.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 1fe203c56faf..2fe2add62a8e 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -905,7 +905,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 = memdup_user_nul(optval, optlen); |