mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Kees Cook <keescook@chromium.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	linux-block@vger.kernel.org, Eric Biggers <ebiggers@google.com>,
	"open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
	<linux-crypto@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH crypto-next 07/23] block: cryptoloop: Remove VLA usage of skcipher
Date: Tue, 25 Sep 2018 10:03:27 -0600	[thread overview]
Message-ID: <9c71afda-a668-10b3-842e-26f72e425691@kernel.dk> (raw)
In-Reply-To: <CAKv+Gu-xKWsiegZXnsMvmMVgKTo7S2cm4wEqdaL7w9z64X7SAA@mail.gmail.com>

On 9/25/18 3:25 AM, Ard Biesheuvel wrote:
> On Mon, 24 Sep 2018 at 19:53, Kees Cook <keescook@chromium.org> wrote:
>>
>> On Mon, Sep 24, 2018 at 4:52 AM, Ard Biesheuvel
>> <ard.biesheuvel@linaro.org> wrote:
>>> On Wed, 19 Sep 2018 at 04:11, Kees Cook <keescook@chromium.org> wrote:
>>>> @@ -119,7 +119,7 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
>>>>         unsigned in_offs, out_offs;
>>>>         int err;
>>>>
>>>> -       skcipher_request_set_tfm(req, tfm);
>>>> +       skcipher_request_set_sync_tfm(req, tfm);
>>>>         skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP,
>>>>                                       NULL, NULL);
>>>>
>>>
>>> Does this work?
>>
>> Everything is a direct wrapper for existing types and functions, so I
>> wouldn't expect any functional change. I haven't been able to test
>> this particular interface, though. cryptoloop is very deprecated,
>> isn't it?
>>
> 
> Ah yes, I managed to confuse myself there. This looks all fine to me.
> 
> In any case, this is another example where we may decide to fix the
> code rather than retain the request allocation on the stack (but that
> is Jens's call ultimately, I suppose)
> 
> diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
> index 7033a4beda66..5ed2167219ba 100644
> --- a/drivers/block/cryptoloop.c
> +++ b/drivers/block/cryptoloop.c
> @@ -110,7 +110,7 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
>                     int size, sector_t IV)
>  {
>         struct crypto_skcipher *tfm = lo->key_data;
> -       SKCIPHER_REQUEST_ON_STACK(req, tfm);
> +       struct skcipher_request *req;
>         struct scatterlist sg_out;
>         struct scatterlist sg_in;
> 
> @@ -119,7 +119,10 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
>         unsigned in_offs, out_offs;
>         int err;
> 
> -       skcipher_request_set_tfm(req, tfm);
> +       req = skcipher_request_alloc(tfm, GFP_NOIO);
> +       if (!req)
> +               return -ENOMEM;

Is this going to be reliable? ->transfer() is called when we're doing IO,
and you'd normally need a mempool backed allocation to make this safe
and guarantee forward progress.

-- 
Jens Axboe


  reply	other threads:[~2018-09-25 16:03 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19  2:10 [PATCH crypto-next 00/23] crypto: skcipher - Remove VLA usage Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 01/23] crypto: skcipher - Introduce crypto_sync_skcipher Kees Cook
2018-09-24 11:48   ` Ard Biesheuvel
2018-09-19  2:10 ` [PATCH crypto-next 02/23] gss_krb5: Remove VLA usage of skcipher Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 03/23] lib80211: " Kees Cook
2018-09-19 20:37   ` Johannes Berg
2018-09-19  2:10 ` [PATCH crypto-next 04/23] mac802154: " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 05/23] s390/crypto: " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 06/23] x86/fpu: " Kees Cook
2018-09-24 11:45   ` Ard Biesheuvel
2018-09-24 17:35     ` Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 07/23] block: cryptoloop: " Kees Cook
2018-09-24 11:52   ` Ard Biesheuvel
2018-09-24 17:53     ` Kees Cook
2018-09-25  9:25       ` Ard Biesheuvel
2018-09-25 16:03         ` Jens Axboe [this message]
2018-09-25 16:16           ` Ard Biesheuvel
2018-09-25 16:32             ` Jens Axboe
2018-09-26  8:19               ` Ard Biesheuvel
2018-09-19  2:10 ` [PATCH crypto-next 08/23] libceph: " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 09/23] ppp: mppe: " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 10/23] rxrpc: " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 11/23] wusb: " Kees Cook
2018-09-20 10:39   ` Greg Kroah-Hartman
2018-09-19  2:10 ` [PATCH crypto-next 12/23] crypto: ccp - " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 13/23] crypto: vmx " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 14/23] crypto: null " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 15/23] crypto: cryptd " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 16/23] crypto: sahara " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 17/23] crypto: qce " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 18/23] crypto: artpec6 " Kees Cook
2018-09-23 12:13   ` Lars Persson
2018-09-19  2:10 ` [PATCH crypto-next 19/23] crypto: chelsio " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 20/23] crypto: mxs-dcp " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 21/23] crypto: omap-aes " Kees Cook
2018-09-19  2:10 ` [PATCH crypto-next 22/23] crypto: picoxcell " Kees Cook
2018-09-19  2:11 ` [PATCH crypto-next 23/23] crypto: skcipher - Remove SKCIPHER_REQUEST_ON_STACK() Kees Cook
2018-09-25  0:49 ` [PATCH crypto-next 00/23] crypto: skcipher - Remove VLA usage Kees Cook
2018-09-25  4:49   ` Herbert Xu
2018-09-25 15:39     ` Kees Cook
2018-09-28  5:08 ` Herbert Xu
2018-09-28 16:13   ` Kees Cook

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=9c71afda-a668-10b3-842e-26f72e425691@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=ard.biesheuvel@linaro.org \
    --cc=ebiggers@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=keescook@chromium.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome