two small fixes for sctp key usage
Subsystems (3)
cover two small fixes for sctp key usage
Cryptographically used keys should be zeroed out when our session ends resp. memory is freed, thus do not leave them somewhere in the memory.
Daniel Borkmann (2):
net: sctp: sctp_setsockopt_auth_key: use kzfree instead of kfree
net: sctp: sctp_endpoint_free: zero out secret key data
net/sctp/endpointola.c | 5 +++++ net/sctp/socket.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.11.7
PATCH 1/2 net: sctp: sctp_setsockopt_auth_key: use kzfree instead of kfree
In sctp_setsockopt_auth_key, we create a temporary copy of the user passed shared auth key for the endpoint or association and after internal setup, we free it right away. Since it's sensitive data, we should zero out the key before returning the memory back to the allocator. Thus, use kzfree instead of kfree, just as we do in sctp_auth_key_put().
--- net/sctp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/socket.c +1 -1
@@ -3390,7 +3390,7 @@ static int sctp_setsockopt_auth_key(struct sock *sk, ret =sctp_auth_set_key (sctp_sk (sk)->ep, asoc, authkey); out: -kfree (authkey); +kzfree (authkey);return ret; }
Signature · 1 line
1.7.11.7
PATCH 2/2 net: sctp: sctp_endpoint_free: zero out secret key data
In reply to Daniel BorkmannOn sctp_endpoint_destroy, previously used sensitive keying material should be zeroed out before the memory is returned, as we already do with e.g. auth keys when released.
--- net/sctp/endpointola.c | 5 +++++ 1 file changed, 5 insertions(+)
net/sctp/endpointola.c +5 -0
@@ -249,6 +249,8 @@ void sctp_endpoint_free(struct sctp_endpoint *ep)/* Final destructor for endpoint. */ static void sctp_endpoint_destroy (struct sctp_endpoint *ep) { +int i; +SCTP_ASSERT (ep->base.dead,"Endpoint is not dead" , return);/* Free up the HMAC transform. */
@@ -271,6 +273,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)sctp_inq_free (&ep->base.inqueue);sctp_bind_addr_free (&ep->base.bind_addr); +for (i =0 ; i <SCTP_HOW_MANY_SECRETS ; ++i) +memset (&ep->secret_key[i],0 ,SCTP_SECRET_SIZE ); +/* Remove and free the port */ if (sctp_sk (ep->base.sk)->bind_hash)sctp_put_port (ep->base.sk);
Signature · 1 line
1.7.11.7
Re: [PATCH net 2/2] net: sctp: sctp_endpoint_free: zero out secret key data
Quoted 5 lines · Daniel Borkmann
On
sctp_endpoint_destroy, previously used sensitive keying material should be zeroed out before the memory is returned, as we already do with e.g. auth keys when released.Signed-off-by Daniel Borkmann <[email protected]>
I'll ack this, but the whole multiple cookie keys code is completely unused and has been all this time. Noone uses anything other then the secret_key[0] since there is no changeover support anywhere. It might be nice to clean that up too.
-vlad
Quoted 19 lines
--- net/sctp/endpointola.c | 5 +++++ 1 file changed, 5 insertions(+)net/sctp/endpointola.c +2
-0@@ -249,6 +249,8 @@ void sctp_endpoint_free(struct sctp_endpoint *ep)/* Final destructor for endpoint. */ static void sctp_endpoint_destroy (struct sctp_endpoint *ep) { +int i; +SCTP_ASSERT (ep->base.dead,"Endpoint is not dead" , return);/* Free up the HMAC transform. */
net/sctp/endpointola.c static void sctp_endpoint_destroy(struct sctp_endpoint *ep) · line 281
Quoted 9 lines
net/sctp/endpointola.c +3
-0@@ -271,6 +273,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)sctp_inq_free (&ep->base.inqueue);sctp_bind_addr_free (&ep->base.bind_addr); +for (i =0 ; i <SCTP_HOW_MANY_SECRETS ; ++i) +memset (&ep->secret_key[i],0 ,SCTP_SECRET_SIZE ); +/* Remove and free the port */ if (sctp_sk (ep->base.sk)->bind_hash)sctp_put_port (ep->base.sk);
c
If
Re: [PATCH net 2/2] net: sctp: sctp_endpoint_free: zero out secret key data
Quoted 8 lines · Vlad Yasevich
Quoted 5 lines · Daniel Borkmann
On
sctp_endpoint_destroy, previously used sensitive keying material should be zeroed out before the memory is returned, as we already do with e.g. auth keys when released.Signed-off-by Daniel Borkmann <[email protected]>I'll ack this, but the whole multiple cookie keys code is completely unused and has been all this time. Noone uses anything other then the secret_key[0] since there is no changeover support anywhere. It might be nice to clean that up too.
Put on my todo list for follow-up patches, thanks.
Quoted 36 lines
Acked-by Vlad Yasevich <[email protected]>-vlad
Quoted 19 lines
--- net/sctp/endpointola.c | 5 +++++ 1 file changed, 5 insertions(+)net/sctp/endpointola.c +2
-0@@ -249,6 +249,8 @@ void sctp_endpoint_free(struct sctp_endpoint *ep)/* Final destructor for endpoint. */ static void sctp_endpoint_destroy (struct sctp_endpoint *ep) { +int i; +SCTP_ASSERT (ep->base.dead,"Endpoint is not dead" , return);/* Free up the HMAC transform. */ net/sctp/endpointola.c static void sctp_endpoint_destroy(struct sctp_endpoint *ep) · line 281
Quoted 9 lines
net/sctp/endpointola.c +3
-0@@ -271,6 +273,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)sctp_inq_free (&ep->base.inqueue);sctp_bind_addr_free (&ep->base.bind_addr); +for (i =0 ; i <SCTP_HOW_MANY_SECRETS ; ++i) +memset (&ep->secret_key[i],0 ,SCTP_SECRET_SIZE ); +/* Remove and free the port */ if (sctp_sk (ep->base.sk)->bind_hash)sctp_put_port (ep->base.sk);c
If
David Miller
maintainerFrom: Daniel Borkmann <[email protected]>
Date: Fri, 8 Feb 2013 14:04:33 +0100
Quoted 7 lines
Cryptographically used keys should be zeroed out when our session ends resp. memory is freed, thus do not leave them somewhere in the memory.
Daniel Borkmann (2):
net: sctp:sctp_setsockopt_auth_key: use kzfree instead of kfree
net: sctp:sctp_endpoint_free: zero out secret key data
Applied and queued up for -stable, thanks.