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 11:55:58 +0200 |
| commit | 78272109f44d9bf3925da12ce1fa62c644a1af6a (patch) | |
| tree | aa49c8cef42cebda2b43a91e04cd1d3b80345c78 | |
| parent | bf123536563755173a8879ebc9a0319189c1f1ad (diff) | |
| download | linux-78272109f44d9bf3925da12ce1fa62c644a1af6a.tar.gz linux-78272109f44d9bf3925da12ce1fa62c644a1af6a.tar.bz2 linux-78272109f44d9bf3925da12ce1fa62c644a1af6a.zip | |
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/key.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 64cbbd2f1694..85a9ff8cd236 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -903,7 +903,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); |
