diff mbox

[5/5] libceph: fix error handling in process_one_ticket()

Message ID 1495557238-1077-6-git-send-email-idryomov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ilya Dryomov May 23, 2017, 4:33 p.m. UTC
Don't leak key internals after new_session_key is populated.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 net/ceph/auth_x.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Alex Elder May 23, 2017, 5:47 p.m. UTC | #1
On 05/23/2017 11:33 AM, Ilya Dryomov wrote:
> Don't leak key internals after new_session_key is populated.
> 
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

Hmmm.  This is a good change.  Perhaps ceph_crypto_key_destroy()
could zero the pointed-to ceph_crypto_key?

Anyway, this looks good.

Reviewed-by: Alex Elder <elder@linaro.org>

> ---
>  net/ceph/auth_x.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
> index d0126df33f1f..8757fb87dab8 100644
> --- a/net/ceph/auth_x.c
> +++ b/net/ceph/auth_x.c
> @@ -151,7 +151,7 @@ static int process_one_ticket(struct ceph_auth_client *ac,
>  	struct timespec validity;
>  	void *tp, *tpend;
>  	void **ptp;
> -	struct ceph_crypto_key new_session_key;
> +	struct ceph_crypto_key new_session_key = { 0 };
>  	struct ceph_buffer *new_ticket_blob;
>  	unsigned long new_expires, new_renew_after;
>  	u64 new_secret_id;
> @@ -237,13 +237,13 @@ static int process_one_ticket(struct ceph_auth_client *ac,
>  	     type, ceph_entity_type_name(type), th->secret_id,
>  	     (int)th->ticket_blob->vec.iov_len);
>  	xi->have_keys |= th->service;
> -
> -out:
> -	return ret;
> +	return 0;
>  
>  bad:
>  	ret = -EINVAL;
> -	goto out;
> +out:
> +	ceph_crypto_key_destroy(&new_session_key);
> +	return ret;
>  }
>  
>  static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
index d0126df33f1f..8757fb87dab8 100644
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -151,7 +151,7 @@  static int process_one_ticket(struct ceph_auth_client *ac,
 	struct timespec validity;
 	void *tp, *tpend;
 	void **ptp;
-	struct ceph_crypto_key new_session_key;
+	struct ceph_crypto_key new_session_key = { 0 };
 	struct ceph_buffer *new_ticket_blob;
 	unsigned long new_expires, new_renew_after;
 	u64 new_secret_id;
@@ -237,13 +237,13 @@  static int process_one_ticket(struct ceph_auth_client *ac,
 	     type, ceph_entity_type_name(type), th->secret_id,
 	     (int)th->ticket_blob->vec.iov_len);
 	xi->have_keys |= th->service;
-
-out:
-	return ret;
+	return 0;
 
 bad:
 	ret = -EINVAL;
-	goto out;
+out:
+	ceph_crypto_key_destroy(&new_session_key);
+	return ret;
 }
 
 static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,