From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: Roberto Sassu <roberto.sassu@polito.it>
Cc: linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, keyrings@linux-nfs.org,
linux-crypto@vger.kernel.org, David Howells <dhowells@redhat.com>,
James Morris <jmorris@namei.org>,
David Safford <safford@watson.ibm.com>,
Rajiv Andrade <srajiv@linux.vnet.ibm.com>,
Mimi Zohar <zohar@us.ibm.com>
Subject: Re: [PATCH v1.1 4/4] keys: add new key-type encrypted
Date: Tue, 02 Nov 2010 06:56:52 -0400 [thread overview]
Message-ID: <1288695412.16939.3.camel@localhost.localdomain> (raw)
In-Reply-To: <201011021030.27253.roberto.sassu@polito.it>
On Tue, 2010-11-02 at 10:30 +0100, Roberto Sassu wrote:
> The buffer 'derived_buf' in the function get_derived_key() must be
> allocated dynamically in order to make room for an arbitrary length
> master key.
>
> Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
> ---
> security/keys/encrypted_defined.c | 15 +++++++++++++--
> 1 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/security/keys/encrypted_defined.c b/security/keys/encrypted_defined.c
> index 5331925..65d9b13 100644
> --- a/security/keys/encrypted_defined.c
> +++ b/security/keys/encrypted_defined.c
> @@ -289,10 +289,20 @@ enum derived_key_type { ENC_KEY, AUTH_KEY };
> static int get_derived_key(char *derived_key, enum derived_key_type key_type,
> void *master_key, unsigned int master_keylen)
> {
> - char derived_buf[hash_size + 10];
> + char *derived_buf;
> int ret;
> + unsigned int derived_buf_len;
> +
> + derived_buf_len = strlen("AUTH_KEY") + 1 + master_keylen;
> + if (derived_buf_len < hash_size)
> + derived_buf_len = hash_size;
> +
> + derived_buf = kzalloc(derived_buf_len, GFP_KERNEL);
> + if (!derived_buf) {
> + pr_err("encrypted_key: out of memory\n");
> + return -ENOMEM;
> + }
>
> - memset(derived_buf, 0, sizeof derived_buf);
Thanks Roberto!
> if (key_type)
> strcpy(derived_buf, "AUTH_KEY");
> else
> @@ -301,6 +311,7 @@ static int get_derived_key(char *derived_key, enum derived_key_type key_type,
> memcpy(derived_buf + strlen(derived_buf) + 1, master_key,
> master_keylen);
> ret = calc_hash(derived_key, derived_buf, sizeof derived_buf);
> + kfree(derived_buf);
> return ret;
> }
>
Yes, and the length in calc_hash() would then need to be
derived_buf_len.
thanks,
Mimi
prev parent reply other threads:[~2010-11-02 10:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-11 20:11 [PATCH v1.1 0/4] keys: trusted and encrypted keys Mimi Zohar
2010-10-11 20:11 ` [PATCH v1.1 1/4] lib: hex2bin converts ascii hexadecimal string to binary Mimi Zohar
2010-10-11 20:11 ` [PATCH v1.1 2/4] key: add tpm_send command Mimi Zohar
2010-10-11 20:11 ` [PATCH v1.1 3/4] keys: add new trusted key-type Mimi Zohar
2010-10-12 1:22 ` Serge E. Hallyn
2010-10-12 20:19 ` Mimi Zohar
2010-10-11 20:11 ` [PATCH v1.1 4/4] keys: add new key-type encrypted Mimi Zohar
2010-11-02 9:30 ` Roberto Sassu
2010-11-02 10:56 ` Mimi Zohar [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=1288695412.16939.3.camel@localhost.localdomain \
--to=zohar@linux.vnet.ibm.com \
--cc=dhowells@redhat.com \
--cc=jmorris@namei.org \
--cc=keyrings@linux-nfs.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=roberto.sassu@polito.it \
--cc=safford@watson.ibm.com \
--cc=srajiv@linux.vnet.ibm.com \
--cc=zohar@us.ibm.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).