From: Sowmini Varadhan <sowmini.varadhan@oracle.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: dhowells@redhat.com, linux-crypto@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>
Subject: Re: unaligned access in pkcs7_verify
Date: Tue, 13 Oct 2015 09:29:28 -0400 [thread overview]
Message-ID: <20151013132928.GK20800@oracle.com> (raw)
In-Reply-To: <20151012133209.GA27746@gondor.apana.org.au>
On (10/12/15 21:32), Herbert Xu wrote:
>
> .. pkcs7_verify definitely
> shouldn't place the structure after the digest without aligning the
> pointer. So something like your patch is needed (but please use
> alignof instead of sizeof). Also don't put in digest_size but
> instead align the pointer like
>
> desc = PTR_ALIGN(digest + digest_size, ...)
I tried the patch below for 24+ hours, and it ran without mishaps.
But given that the panics I saw earlier (page faults typically
triggered by openswan's pluto) occurred unpredictably, it would be
useful to have an expert-review of this code.
Thanks,
--Sowmini
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
index d20c0b4..958ac01 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -46,14 +46,15 @@ static int pkcs7_digest(struct pkcs7_message *pkcs7,
return (PTR_ERR(tfm) == -ENOENT) ? -ENOPKG : PTR_ERR(tfm);
desc_size = crypto_shash_descsize(tfm) + sizeof(*desc);
- sinfo->sig.digest_size = digest_size = crypto_shash_digestsize(tfm);
-
+ sinfo->sig.digest_size = crypto_shash_digestsize(tfm);
+ digest_size = crypto_shash_digestsize(tfm) +
+ ALIGN(crypto_shash_digestsize(tfm), __alignof__(*desc));
ret = -ENOMEM;
digest = kzalloc(digest_size + desc_size, GFP_KERNEL);
if (!digest)
goto error_no_desc;
- desc = digest + digest_size;
+ desc = PTR_ALIGN(digest + digest_size, __alignof__(*desc));
desc->tfm = tfm;
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
next prev parent reply other threads:[~2015-10-13 13:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 14:00 unaligned access in pkcs7_verify Sowmini Varadhan
2015-10-08 13:15 ` Herbert Xu
2015-10-08 14:43 ` Sowmini Varadhan
2015-10-12 13:32 ` Herbert Xu
2015-10-12 13:46 ` Sowmini Varadhan
2015-10-12 14:06 ` David Miller
2015-10-13 13:39 ` Herbert Xu
2015-10-13 13:29 ` Sowmini Varadhan [this message]
2015-10-13 13:36 ` Herbert Xu
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=20151013132928.GK20800@oracle.com \
--to=sowmini.varadhan@oracle.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/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.