From: David Howells Date: Fri, 2 Oct 2020 13:04:51 +0000 (+0100) Subject: rxrpc: Fix server keyring leak X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=38b1dc47a35ba14c3f4472138ea56d014c2d609b;p=linux.git 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 --- diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 75e84ed4fa63d..2e8bd3b97301e 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);