From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: liushuoran <liushuoran@huawei.com>,
Xiakaixu <xiakaixu@huawei.com>,
"David S. Miller" <davem@davemloft.net>,
"Theodore Ts'o" <tytso@mit.edu>, Jaegeuk Kim <jaegeuk@kernel.org>,
"nhorman@tuxdriver.com" <nhorman@tuxdriver.com>,
"mh1@iki.fi" <mh1@iki.fi>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Wangbintian <bintian.wang@huawei.com>,
Huxinwei <huxinwei@huawei.com>,
"zhangzhibin (C)" <zhangzhibin.zhang@huawei.com>
Subject: Re: Kernel panic - encryption/decryption failed when open file on Arm64
Date: Tue, 13 Sep 2016 08:56:50 +0100 [thread overview]
Message-ID: <CAKv+Gu9y_UDadH1Qu1b=rRmoagEjHj40Y3OHEredHxP5np_zrQ@mail.gmail.com> (raw)
In-Reply-To: <20160913064329.GA26933@gondor.apana.org.au>
On 13 September 2016 at 07:43, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Mon, Sep 12, 2016 at 06:40:15PM +0100, Ard Biesheuvel wrote:
>>
>> So to me, it seems like we should be taking the blkcipher_next_slow()
>> path, which does a kmalloc() and bails with -ENOMEM if that fails.
>
> Indeed. This was broken a long time ago. It does seem to be
> fixed in the new skcipher_walk code but here is a patch to fix
> it for older kernels.
>
> ---8<---
> Subject: crypto: skcipher - Fix blkcipher walk OOM crash
>
> When we need to allocate a temporary blkcipher_walk_next and it
> fails, the code is supposed to take the slow path of processing
> the data block by block. However, due to an unrelated change
> we instead end up dereferencing the NULL pointer.
>
> This patch fixes it by moving the unrelated bsize setting out
> of the way so that we enter the slow path as inteded.
>
inteNded ^^^
> Fixes: 7607bd8ff03b ("[CRYPTO] blkcipher: Added blkcipher_walk_virt_block")
> Cc: stable@vger.kernel.org
> Reported-by: xiakaixu <xiakaixu@huawei.com>
> Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
This fixes the issue for me
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
I will follow up with fixes for the ARM and arm64 CTR code shortly.
Thanks,
Ard.
> diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
> index 3699995..a832426 100644
> --- a/crypto/blkcipher.c
> +++ b/crypto/blkcipher.c
> @@ -233,6 +233,8 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc,
> return blkcipher_walk_done(desc, walk, -EINVAL);
> }
>
> + bsize = min(walk->walk_blocksize, n);
> +
> walk->flags &= ~(BLKCIPHER_WALK_SLOW | BLKCIPHER_WALK_COPY |
> BLKCIPHER_WALK_DIFF);
> if (!scatterwalk_aligned(&walk->in, walk->alignmask) ||
> @@ -245,7 +247,6 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc,
> }
> }
>
> - bsize = min(walk->walk_blocksize, n);
> n = scatterwalk_clamp(&walk->in, n);
> n = scatterwalk_clamp(&walk->out, n);
>
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
prev parent reply other threads:[~2016-09-13 7:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <57D15BD3.40903@huawei.com>
2016-09-08 12:47 ` Kernel panic - encryption/decryption failed when open file on Arm64 Herbert Xu
2016-09-09 4:08 ` xiakaixu
2016-09-09 10:19 ` xiakaixu
2016-09-09 10:31 ` Ard Biesheuvel
2016-09-09 10:56 ` Ard Biesheuvel
2016-09-12 2:16 ` liushuoran
2016-09-12 17:40 ` Ard Biesheuvel
2016-09-13 2:05 ` xiakaixu
2016-09-13 6:43 ` Herbert Xu
2016-09-13 7:56 ` Ard Biesheuvel [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='CAKv+Gu9y_UDadH1Qu1b=rRmoagEjHj40Y3OHEredHxP5np_zrQ@mail.gmail.com' \
--to=ard.biesheuvel@linaro.org \
--cc=bintian.wang@huawei.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=huxinwei@huawei.com \
--cc=jaegeuk@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liushuoran@huawei.com \
--cc=mh1@iki.fi \
--cc=nhorman@tuxdriver.com \
--cc=tytso@mit.edu \
--cc=xiakaixu@huawei.com \
--cc=zhangzhibin.zhang@huawei.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).