All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabrizio Demaria <fabrizio.f.demaria@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, "Nordell,
	Joakim" <joakim.nordell@intel.com>,
	"Chen, Shujuan" <shujuan.chen@intel.com>,
	doru.gucea@intel.com
Subject: Re: "crypto_hash_setkey" call from atomic context
Date: Mon, 14 Dec 2015 09:53:03 +0100	[thread overview]
Message-ID: <CACzeOEfOSi7T2CmE1HjU-ryCGEBj-b0h2E-o0BrmKWiFvMcEHQ@mail.gmail.com> (raw)
In-Reply-To: <20151211074223.GA11688@gondor.apana.org.au>

In our MPTCP implementation we handled the setkey problem by
pre-allocating a properly aligned key's buffer right after
"crypto_alloc_hash", outside atomic context [1]. Would this workaround
be enough to guarantee that "crypto_hash_setkey" can be safely called
in atomic contexts? Is it always the case that "crypto_hash_setkey"
calls "crypto_shash_setkey"?

Thanks,
Fabrizio

[1] https://github.com/multipath-tcp/mptcp_net-next/commit/06e7644bdac1ac6e97767bc714586fbfadcdeaa8

2015-12-11 8:42 GMT+01:00 Herbert Xu <herbert@gondor.apana.org.au>:
> Fabrizio Demaria <fabrizio.f.demaria@gmail.com> wrote:
>> Hello,
>>
>> I am investigating the current usage of kernel crypto-libraries in the
>> SCTP code, considering to adopt the same crypto framework for the
>> MPTCP implementation.
>>
>> In sm_make_chunk.c, the crypto function "crypto_hash_setkey" is called
>> in an atomic context, despite the fact that this function CAN invoke a
>> GFP_KERNEL (sleeping) memory allocation. Calling a sleeping function
>> from an atomic context can end up in deadlock.
>> Is there a way to make sure that “crypto_hash_setkey” can be safely
>> called in an atomic context, considering all the possible code-paths
>> followed by the function?
>
> Indeed, in general setkey should not be invoked in atomic contexts.
> The only exception would be extremely simple hashes such as CRC.
>
> Keys should be setup before hand.  So SCTP needs to be fixed.
>
> Cheers,
> --
> 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

  reply	other threads:[~2015-12-14  8:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 15:59 "crypto_hash_setkey" call from atomic context Fabrizio Demaria
2015-12-11  7:42 ` Herbert Xu
2015-12-14  8:53   ` Fabrizio Demaria [this message]
2015-12-14  9:57     ` 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=CACzeOEfOSi7T2CmE1HjU-ryCGEBj-b0h2E-o0BrmKWiFvMcEHQ@mail.gmail.com \
    --to=fabrizio.f.demaria@gmail.com \
    --cc=doru.gucea@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=joakim.nordell@intel.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=shujuan.chen@intel.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 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.