LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jesper Juhl <jj@chaosbits.net>
To: "Paoloni, Gabriele" <gabriele.paoloni@intel.com>,
Herbert Xu <herbert@gondor.hengli.com.au>,
tadeusz.struk@intel.com
Cc: Pavel Machek <pavel@ucw.cz>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"O Mahony, Aidan" <aidan.o.mahony@intel.com>,
"Hoban, Adrian" <adrian.hoban@intel.com>
Subject: RE: [PATCH](updated) rfc4106, Intel, AES-NI: Don't leak memory in rfc4106_set_hash_subkey()..
Date: Fri, 11 Feb 2011 22:09:22 +0100 (CET) [thread overview]
Message-ID: <alpine.LNX.2.00.1102112204020.16994@swampdragon.chaosbits.net> (raw)
In-Reply-To: <alpine.LNX.2.00.1102111546310.13370@swampdragon.chaosbits.net>
On Fri, 11 Feb 2011, Jesper Juhl wrote:
> On Fri, 11 Feb 2011, Paoloni, Gabriele wrote:
>
> > Well anyway I think that the return value of "ablkcipher_request_alloc(ctr_tfm, GFP_KERNEL)" has to be changed from -EINVAL to -ENOMEM in case of failure. That is why would stay on the patch that Tadeusz proposed. Otherwise Juhl should send another one....
> >
> I'll take a look again later this evening when I get home from work.
>
Hopefully this takes care of all complaints and can actually get merged so
we can get the leak fixed (patch is against current cryptodev-2.6 tree).
Fix up previous patch that failed to properly fix mem leak in
rfc4106_set_hash_subkey(). This add-on patch; fixes the leak. moves
kfree() out of the error path, returns -ENOMEM rather than -EINVAL when
ablkcipher_request_alloc() fails.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
aesni-intel_glue.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index e013552..502b76d 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -876,17 +876,15 @@ rfc4106_set_hash_subkey(u8 *hash_subkey, const u8 *key, unsigned int key_len)
if (ret)
goto out;
+ ret = -ENOMEM;
req = ablkcipher_request_alloc(ctr_tfm, GFP_KERNEL);
- if (!req) {
- ret = -EINVAL;
+ if (!req)
goto out_free_ablkcipher;
- }
req_data = kmalloc(sizeof(*req_data), GFP_KERNEL);
- if (!req_data) {
- ret = -ENOMEM;
+ if (!req_data)
goto out_free_request;
- }
+
memset(req_data->iv, 0, sizeof(req_data->iv));
/* Clear the data in the hash sub key container to zero.*/
@@ -911,12 +909,11 @@ rfc4106_set_hash_subkey(u8 *hash_subkey, const u8 *key, unsigned int key_len)
if (!ret)
ret = req_data->result.err;
}
+ kfree(req_data);
out_free_request:
ablkcipher_request_free(req);
- kfree(req_data);
out_free_ablkcipher:
crypto_free_ablkcipher(ctr_tfm);
-out:
return ret;
}
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
next prev parent reply other threads:[~2011-02-11 21:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 17:32 [PATCH] " tadeusz.struk
2011-02-07 18:24 ` Jesper Juhl
2011-02-11 14:26 ` Pavel Machek
2011-02-11 14:38 ` Paoloni, Gabriele
2011-02-11 14:47 ` Jesper Juhl
2011-02-11 21:09 ` Jesper Juhl [this message]
2011-02-11 21:14 ` [PATCH](updated) " Jesper Juhl
2011-02-16 2:04 ` Herbert Xu
2011-02-07 21:09 ` [PATCH] " Herbert Xu
2011-02-10 18:47 ` Jesper Juhl
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=alpine.LNX.2.00.1102112204020.16994@swampdragon.chaosbits.net \
--to=jj@chaosbits.net \
--cc=adrian.hoban@intel.com \
--cc=aidan.o.mahony@intel.com \
--cc=gabriele.paoloni@intel.com \
--cc=herbert@gondor.hengli.com.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=tadeusz.struk@intel.com \
--subject='RE: [PATCH](updated) rfc4106, Intel, AES-NI: Don'\''t leak memory in rfc4106_set_hash_subkey()..' \
/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
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).