Skip to content

Commit

Permalink
rxrpc: Fix server keyring leak
Browse files Browse the repository at this point in the history
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: 17926a7 ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both")
Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed Oct 5, 2020
1 parent fea9911 commit 38b1dc4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/rxrpc/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 38b1dc4

Please sign in to comment.