Commit 38b1dc47 authored by David Howells's avatar David Howells
Browse files

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: 17926a79 ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both")
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent fea99111
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);