Skip to content

Commit a1c83b0

Browse files
committed
Merge branch 'sctp_keys'
Daniel Borkmann says: ==================== Cryptographically used keys should be zeroed out when our session ends resp. memory is freed, thus do not leave them somewhere in the memory. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents ab54ee8 + b5c37fe commit a1c83b0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

net/sctp/endpointola.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ void sctp_endpoint_free(struct sctp_endpoint *ep)
249249
/* Final destructor for endpoint. */
250250
static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
251251
{
252+
int i;
253+
252254
SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);
253255

254256
/* Free up the HMAC transform. */
@@ -271,6 +273,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
271273
sctp_inq_free(&ep->base.inqueue);
272274
sctp_bind_addr_free(&ep->base.bind_addr);
273275

276+
for (i = 0; i < SCTP_HOW_MANY_SECRETS; ++i)
277+
memset(&ep->secret_key[i], 0, SCTP_SECRET_SIZE);
278+
274279
/* Remove and free the port */
275280
if (sctp_sk(ep->base.sk)->bind_hash)
276281
sctp_put_port(ep->base.sk);

net/sctp/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3390,7 +3390,7 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
33903390

33913391
ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey);
33923392
out:
3393-
kfree(authkey);
3393+
kzfree(authkey);
33943394
return ret;
33953395
}
33963396

0 commit comments

Comments
 (0)