linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* crypto API and GFP_ATOMIC
@ 2020-06-09 17:11 Mikulas Patocka
  2020-06-10  1:04 ` Herbert Xu
  0 siblings, 1 reply; 46+ messages in thread
From: Mikulas Patocka @ 2020-06-09 17:11 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller
  Cc: linux-crypto, Mike Snitzer, Milan Broz, dm-devel, linux-kernel

Hi

I've found out that a lot of hardware crypto drivers use GFP_ATOMIC. Some 
of them switch between GFP_ATOMIC and GFP_KERNEL based on the flag 
CRYPTO_TFM_REQ_MAY_SLEEP.

dm-crypt and dm-integrity don't use CRYPTO_TFM_REQ_MAY_SLEEP (because 
GFP_KERNEL allocation requests can recurse back to the block device 
drivers and cause deadlocks).

So, basically, the crypto requests submitted by dm-crypt and dm-integrity 
can fail anytime. I'd like to ask, how to handle these random -ENOMEM 
return codes. If we pass -ENOMEM back to the block device stack, it could 
cause random I/O errors and data corruption.

The question is - if the crypto request returns -ENOMEM, could we sleep 
and retry it? I thought about it - the problem could be, if the crypto 
requests proceeds hafway through and then returns -ENOMEM, and if we 
retried it, it would cause data corruption, because part of the data would 
be decrypted twice.

Is it safe to assume that when we get -ENOMEM, the crypto driver didn't 
modify anything?

Do you have another idea how to solve this problem?

Mikulas


^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2020-07-01  1:50 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09 17:11 crypto API and GFP_ATOMIC Mikulas Patocka
2020-06-10  1:04 ` Herbert Xu
2020-06-10 12:02   ` Mikulas Patocka
2020-06-10 12:11     ` Herbert Xu
2020-06-16 15:01       ` Mikulas Patocka
2020-06-16 15:01         ` [PATCH 1/4] crypto: introduce CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-16 17:36           ` [dm-devel] " Eric Biggers
2020-06-17 15:08             ` Mikulas Patocka
2020-06-17 15:09               ` [PATCH 1/3] crypto: pass the flag CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-26  4:45                 ` Herbert Xu
2020-06-26 15:17                   ` Mikulas Patocka
2020-06-26 16:16                     ` [PATCH 1/3 v2] crypto: introduce " Mikulas Patocka
2020-06-26 16:46                       ` Eric Biggers
2020-06-26 17:00                         ` [dm-devel] " Eric Biggers
2020-06-28 19:07                           ` Mikulas Patocka
2020-06-28 19:50                             ` Eric Biggers
2020-06-30 13:57                               ` Mikulas Patocka
2020-06-28 20:00                             ` Eric Biggers
2020-06-29 13:17                               ` Mikulas Patocka
2020-06-30 13:45                                 ` Mikulas Patocka
2020-06-28 19:04                         ` Mikulas Patocka
2020-06-28 19:46                           ` Eric Biggers
2020-06-28 19:05                         ` [PATCH 1/3 v3] " Mikulas Patocka
2020-06-30 13:56                           ` [PATCH 1/3 v4] " Mikulas Patocka
2020-06-30 16:35                             ` [dm-devel] " Eric Biggers
2020-06-30 17:01                               ` Mikulas Patocka
2020-06-30 17:02                                 ` [PATCH 1/3 v5] " Mikulas Patocka
2020-06-30 17:57                                 ` [dm-devel] [PATCH 1/3 v4] " Eric Biggers
2020-06-30 18:14                                   ` Mikulas Patocka
2020-06-30 18:15                                     ` [PATCH 1/3 v6] " Mikulas Patocka
2020-07-01  1:49                                       ` Herbert Xu
2020-06-17 15:10               ` [PATCH 2/3] crypto: set " Mikulas Patocka
2020-06-17 15:11               ` [PATCH 3/3] dm-crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-16 15:01         ` [PATCH 2/4] crypto: pass the flag CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-16 17:42           ` [dm-devel] " Eric Biggers
2020-06-16 15:02         ` [PATCH 3/4] crypto: set " Mikulas Patocka
2020-06-16 17:43           ` [dm-devel] " Eric Biggers
2020-06-16 15:02         ` [PATCH 4/4] crypto: fix the drivers that don't respect CRYPTO_TFM_REQ_MAY_SLEEP Mikulas Patocka
2020-06-16 17:50           ` [dm-devel] " Eric Biggers
2020-06-16 18:18             ` Mikulas Patocka
2020-06-16 18:23               ` Eric Biggers
2020-06-17 13:46                 ` Mikulas Patocka
2020-06-17 13:48                   ` [PATCH 1/2] cpt-crypto: don't sleep of CRYPTO_TFM_REQ_MAY_SLEEP was not specified Mikulas Patocka
2020-06-26  6:07                     ` Herbert Xu
2020-06-17 13:49                   ` [PATCH 2/2] hisilicon-crypto: " Mikulas Patocka
2020-06-17 14:11                     ` [dm-devel] " Jonathan Cameron

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).