netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Vakul Garg <vakul.garg@nxp.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Boris Pismenny <borisp@mellanox.com>,
	Ilya Lesokhin <ilyal@mellanox.com>,
	Aviad Yehezkel <aviadye@mellanox.com>,
	Dave Watson <davejwatson@fb.com>
Subject: Re: [PATCH net 3/3] tls: zero the crypto information from tls_context before freeing
Date: Thu, 6 Sep 2018 09:42:49 +0200	[thread overview]
Message-ID: <20180906074249.GA14270@bistromath.localdomain> (raw)
In-Reply-To: <DB7PR04MB425294A2EA0DA1170CC2C33E8B020@DB7PR04MB4252.eurprd04.prod.outlook.com>

2018-09-05, 13:48:48 +0000, Vakul Garg wrote:
> 
> 
> > -----Original Message-----
> > From: netdev-owner@vger.kernel.org <netdev-owner@vger.kernel.org> On
> > Behalf Of Sabrina Dubroca
> > Sent: Wednesday, September 5, 2018 6:52 PM
> > To: netdev@vger.kernel.org
> > Cc: Sabrina Dubroca <sd@queasysnail.net>; Boris Pismenny
> > <borisp@mellanox.com>; Ilya Lesokhin <ilyal@mellanox.com>; Aviad
> > Yehezkel <aviadye@mellanox.com>; Dave Watson <davejwatson@fb.com>
> > Subject: [PATCH net 3/3] tls: zero the crypto information from tls_context
> > before freeing
> > 
> > This contains key material in crypto_send_aes_gcm_128 and
> > crypto_recv_aes_gcm_128.
> > 
> > Fixes: 3c4d7559159b ("tls: kernel TLS support")
> > Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> > ---
> >  include/net/tls.h  |  1 +
> >  net/tls/tls_main.c | 14 ++++++++++++--
> >  2 files changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/net/tls.h b/include/net/tls.h index
> > d5c683e8bb22..2010d23112f9 100644
> > --- a/include/net/tls.h
> > +++ b/include/net/tls.h
> > @@ -180,6 +180,7 @@ struct tls_context {
> >  		struct tls_crypto_info crypto_recv;
> >  		struct tls12_crypto_info_aes_gcm_128
> > crypto_recv_aes_gcm_128;
> >  	};
> > +	char tls_crypto_ctx_end[0];
> 
> This makes the key zeroization dependent upon the position of unions
> in structure.

Yes. I could add char tls_crypto_ctx_start[0].

> Can you zeroise the crypto_send, crypto_recv separately using two
> memzero_explicit calls?

It's not crypto_send, it's crypto_send_aes_gcm_128. I don't know how
likely it is that another crypto algorithm will ever be added, but
then you'd have to switch to zeroing that thing.

I had a different version of the patch that gave a name to those
unions, but then I need to change all the references everywhere and
the patch becomes a bit ugly, especially for net.

struct tls_context {
	union {
		struct tls_crypto_info info;
		struct tls12_crypto_info_aes_gcm_128 aes_gcm_128;
	} crypto_send;
	union {
		struct tls_crypto_info info;
		struct tls12_crypto_info_aes_gcm_128 aes_gcm_128;
	} crypto_recv;

	[...]
}


Or even:

union tls_crypto_context {
	struct tls_crypto_info info;
	struct tls12_crypto_info_aes_gcm_128 aes_gcm_128;
};

struct tls_context {
	union tls_crypto_context crypto_send;
	union tls_crypto_context crypto_recv;

	[...]
}


-- 
Sabrina

      reply	other threads:[~2018-09-06 12:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 13:21 [PATCH net 0/3] tls: don't leave keys in kernel memory Sabrina Dubroca
2018-09-05 13:21 ` [PATCH net 1/3] tls: don't copy the key out of tls12_crypto_info_aes_gcm_128 Sabrina Dubroca
2018-09-05 13:21 ` [PATCH net 2/3] tls: clear key material from kernel memory when do_tls_setsockopt_conf fails Sabrina Dubroca
2018-09-05 13:53   ` Boris Pismenny
2018-09-06  7:49     ` Sabrina Dubroca
2018-09-05 13:21 ` [PATCH net 3/3] tls: zero the crypto information from tls_context before freeing Sabrina Dubroca
2018-09-05 13:48   ` Vakul Garg
2018-09-06  7:42     ` Sabrina Dubroca [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180906074249.GA14270@bistromath.localdomain \
    --to=sd@queasysnail.net \
    --cc=aviadye@mellanox.com \
    --cc=borisp@mellanox.com \
    --cc=davejwatson@fb.com \
    --cc=ilyal@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=vakul.garg@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).