]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
rxrpc: Fix server keyring leak
authorDavid Howells <dhowells@redhat.com>
Fri, 2 Oct 2020 13:04:51 +0000 (14:04 +0100)
committerDavid Howells <dhowells@redhat.com>
Mon, 5 Oct 2020 16:09:22 +0000 (17:09 +0100)
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>
net/rxrpc/key.c

index 75e84ed4fa63d10dca3dedc7d075abd214eb07a1..2e8bd3b97301e63461a866c90a42f398b33e0f27 100644 (file)
@@ -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);