From: Mike Snitzer <snitzer@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Milan Broz <mbroz@redhat.com>
Subject: Re: [PATCH 1/3] dm crypt: wipe keys string immediately after key is set
Date: Thu, 3 Feb 2011 10:52:45 -0500 [thread overview]
Message-ID: <20110203155244.GC24255@redhat.com> (raw)
In-Reply-To: <1296691696-23722-1-git-send-email-mbroz@redhat.com>
On Wed, Feb 02 2011 at 7:08pm -0500,
Milan Broz <mbroz@redhat.com> wrote:
> If the tfm key was set up correctly, do not keep another
> copy of key and immediately replace it with zero string.
>
> Signed-off-by: Milan Broz <mbroz@redhat.com>
> ---
> drivers/md/dm-crypt.c | 16 +++++++++++-----
> 1 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
> index 4e054bd..d748433 100644
> --- a/drivers/md/dm-crypt.c
> +++ b/drivers/md/dm-crypt.c
> @@ -1331,20 +1331,26 @@ static int crypt_setkey_allcpus(struct crypt_config *cc)
>
> static int crypt_set_key(struct crypt_config *cc, char *key)
> {
> + int r = -EINVAL, key_string_len = strlen(key);
> +
> /* The key size may not be changed. */
> - if (cc->key_size != (strlen(key) >> 1))
> - return -EINVAL;
> + if (cc->key_size != (key_string_len >> 1))
> + goto out;
>
> /* Hyphen (which gives a key_size of zero) means there is no key. */
> if (!cc->key_size && strcmp(key, "-"))
> - return -EINVAL;
> + goto out;
>
> if (cc->key_size && crypt_decode_key(cc->key, key, cc->key_size) < 0)
> - return -EINVAL;
> + goto out;
>
> set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
>
> - return crypt_setkey_allcpus(cc);
> + r = crypt_setkey_allcpus(cc);
> +out:
> + /* Wipe hexa key string as soon as possible */
s/hexa/hex/ ?
> + memset(key, '0', key_string_len);
> + return r;
> }
>
> static int crypt_wipe_key(struct crypt_config *cc)
Acked-by: Mike Snitzer <snitzer@redhat.com>
prev parent reply other threads:[~2011-02-03 15:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-03 0:08 [PATCH 1/3] dm crypt: wipe keys string immediately after key is set Milan Broz
2011-02-03 0:08 ` [PATCH 2/3] dm ioctl: tidy code for next change Milan Broz
2011-02-03 15:39 ` Mike Snitzer
2011-02-03 0:08 ` [PATCH 3/3] dm ioctl: add data secure (bufer wipe) flag Milan Broz
2011-02-03 15:48 ` Mike Snitzer
2011-02-03 15:52 ` Mike Snitzer [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=20110203155244.GC24255@redhat.com \
--to=snitzer@redhat.com \
--cc=dm-devel@redhat.com \
--cc=mbroz@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.