summaryrefslogtreecommitdiff
path: root/net/rxrpc
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2020-10-02 14:04:51 +0100
committerDavid Howells <dhowells@redhat.com>2020-10-05 17:09:22 +0100
commit38b1dc47a35ba14c3f4472138ea56d014c2d609b (patch)
tree4bb9e068a2a38a03868574a81bbe09ed21c63b63 /net/rxrpc
parentfea99111244bae44e7d82a973744d27ea1567814 (diff)
downloadlwn-38b1dc47a35ba14c3f4472138ea56d014c2d609b.tar.gz
lwn-38b1dc47a35ba14c3f4472138ea56d014c2d609b.zip
rxrpc: Fix server keyring leak
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>
Diffstat (limited to 'net/rxrpc')
-rw-r--r--net/rxrpc/key.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index 75e84ed4fa63..2e8bd3b97301 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -903,7 +903,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, sockptr_t optval, int optlen)
_enter("");
- if (optlen <= 0 || optlen > PAGE_SIZE - 1)
+ if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities)
return -EINVAL;
description = memdup_sockptr_nul(optval, optlen);