linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* cryptomgr_test / drbg_ctr: BUG: sleeping function called from invalid context
@ 2018-05-18  8:36 Geert Uytterhoeven
  2018-05-20 19:54 ` Stephan Müller
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2018-05-18  8:36 UTC (permalink / raw)
  To: Herbert Xu, Stephan Mueller, David S. Miller
  Cc: Linux Crypto Mailing List, Linux Kernel Mailing List

Hi,

After enabling CONFIG_CRYPTO_DRBG_CTR, I start seeing during kernel boot:

BUG: sleeping function called from invalid context at
include/crypto/algapi.h:416
in_atomic(): 1, irqs_disabled(): 0, pid: 203, name: cryptomgr_test
1 lock held by cryptomgr_test/203:
 #0:         (ptrval) (&drbg->drbg_mutex){+.+.}, at: drbg_kcapi_seed+0x128/0x4bc
CPU: 3 PID: 203 Comm: cryptomgr_test Not tainted
4.17.0-rc5-salvator-x-00509-g0ad2b9f404d6a668-dirty #1742
Hardware name: Renesas Salvator-X 2nd version board based on r8a7795 ES2.0+ (DT)
Call trace:
 dump_backtrace+0x0/0x140
 show_stack+0x14/0x1c
 dump_stack+0xb4/0xf0
 ___might_sleep+0x1fc/0x218
 skcipher_walk_done+0x2c8/0x38c
 ctr_encrypt+0x84/0x110
 simd_skcipher_encrypt+0xa4/0xb0
 drbg_kcapi_sym_ctr+0xb4/0x178
 drbg_ctr_update+0x17c/0x2c4
 drbg_seed+0x20c/0x26c
 drbg_kcapi_seed+0x458/0x4bc
 crypto_rng_reset+0x84/0xa8
 alg_test_drbg+0x12c/0x324
 alg_test.part.7+0x264/0x2bc
 alg_test+0x44/0x58
 cryptomgr_test+0x28/0x48
 kthread+0x11c/0x124
 ret_from_fork+0x10/0x18

I tried following the code path, but couldn't find where it went wrong.

mutex_lock(&drbg->drbg_mutex) is called from drbg_instantiate(), which is
inlined by the compiler into drbg_kcapi_seed().

Do you have a clue?
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: cryptomgr_test / drbg_ctr: BUG: sleeping function called from invalid context
  2018-05-18  8:36 cryptomgr_test / drbg_ctr: BUG: sleeping function called from invalid context Geert Uytterhoeven
@ 2018-05-20 19:54 ` Stephan Müller
  2018-06-26 10:33   ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Stephan Müller @ 2018-05-20 19:54 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Herbert Xu, David S. Miller, Linux Crypto Mailing List,
	Linux Kernel Mailing List

Am Freitag, 18. Mai 2018, 10:36:04 CEST schrieb Geert Uytterhoeven:

Hi Geert,
> 
> I tried following the code path, but couldn't find where it went wrong.
> 
> mutex_lock(&drbg->drbg_mutex) is called from drbg_instantiate(), which is
> inlined by the compiler into drbg_kcapi_seed().
> 
> Do you have a clue?

It is the first time I hear from such an issue. Yes, the DRBG should not be 
called in atomic context. But I do not see where we have an atomic context 
(either a spin_lock or in an interrupt handler) when we are executing the test 
manager.

I will keep looking.

Ciao
Stephan

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

* Re: cryptomgr_test / drbg_ctr: BUG: sleeping function called from invalid context
  2018-05-20 19:54 ` Stephan Müller
@ 2018-06-26 10:33   ` Geert Uytterhoeven
  2018-06-26 11:33     ` Stephan Mueller
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2018-06-26 10:33 UTC (permalink / raw)
  To: Stephan Mueller
  Cc: Herbert Xu, David S. Miller, Linux Crypto Mailing List,
	Linux Kernel Mailing List

Hi Stephan,

On Sun, May 20, 2018 at 9:54 PM Stephan Müller <smueller@chronox.de> wrote:
> Am Freitag, 18. Mai 2018, 10:36:04 CEST schrieb Geert Uytterhoeven:
> > I tried following the code path, but couldn't find where it went wrong.
> >
> > mutex_lock(&drbg->drbg_mutex) is called from drbg_instantiate(), which is
> > inlined by the compiler into drbg_kcapi_seed().
> >
> > Do you have a clue?
>
> It is the first time I hear from such an issue. Yes, the DRBG should not be
> called in atomic context. But I do not see where we have an atomic context
> (either a spin_lock or in an interrupt handler) when we are executing the test
> manager.
>
> I will keep looking.

Issue is gone. I assume due to commit 6e88f01206edab0e ("crypto: arm64/aes-blk
- fix and move skcipher_walk_done out of kernel_neon_begin, _end").

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: cryptomgr_test / drbg_ctr: BUG: sleeping function called from invalid context
  2018-06-26 10:33   ` Geert Uytterhoeven
@ 2018-06-26 11:33     ` Stephan Mueller
  0 siblings, 0 replies; 4+ messages in thread
From: Stephan Mueller @ 2018-06-26 11:33 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Herbert Xu, David S. Miller, Linux Crypto Mailing List,
	Linux Kernel Mailing List

Am Dienstag, 26. Juni 2018, 12:33:48 CEST schrieb Geert Uytterhoeven:

Hi Geert,

> Issue is gone. I assume due to commit 6e88f01206edab0e ("crypto:
> arm64/aes-blk - fix and move skcipher_walk_done out of kernel_neon_begin,
> _end").

Thanks a lot for the hint.
> 
> Gr{oetje,eeting}s,
> 
>                         Geert



Ciao
Stephan



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

end of thread, other threads:[~2018-06-26 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-18  8:36 cryptomgr_test / drbg_ctr: BUG: sleeping function called from invalid context Geert Uytterhoeven
2018-05-20 19:54 ` Stephan Müller
2018-06-26 10:33   ` Geert Uytterhoeven
2018-06-26 11:33     ` Stephan Mueller

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