mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] dm-crypt: eboiv/elephant sleeps in softirq with no_read_workqueue
@ 2026-12-01  4:30 Yu Junzhe
  0 siblings, 0 replies; only message in thread
From: Yu Junzhe @ 2026-12-01  4:30 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka, Benjamin Marzinski
  Cc: dm-devel, linux-kernel

Hello,

I am reporting scheduling-while-atomic in dm-crypt IV generation. With
no_read_workqueue, a read is decrypted in the bio completion softirq, and
crypt_iv_eboiv_gen() allocates with GFP_NOIO.

Summary
=======

kcryptd_queue_crypt() calls kcryptd_crypt() inline when no_read_workqueue
is set and the caller is not in hardirq and irqs are enabled. Softirq
completion matches that test.

crypt_iv_eboiv_gen() does:

  req = kmalloc(reqsize + cc->iv_size, GFP_NOIO);
  err = crypto_wait_req(crypto_skcipher_encrypt(req), &wait);

GFP_NOIO can sleep in direct reclaim. crypt_iv_elephant_gen() calls
crypt_iv_eboiv_gen() on every read.

On 6.18.65 the hardirq fallback queues that work to system_bh_wq, which
also cannot sleep. A checkout at v7.1-rc5-6-ge8c2f9fdadee still has the
GFP_NOIO allocation and the softirq inline.

Affected
========

Campaign hit on Linux 6.6.144 (KASAN), crash
70886c5a803fe30fe412ffc7b50c4ffa50b9a801, preempt_count 0x00000101:

  BUG: scheduling while atomic: kworker/1:1H/69/0x00000101
  Workqueue: kblockd blk_mq_run_work_fn
  schedule_timeout
  should_reclaim_retry
  kmalloc
  crypt_iv_eboiv_gen+0x1f1/0x780 drivers/md/dm-crypt.c:762
  crypt_iv_elephant_gen drivers/md/dm-crypt.c:1038
  kcryptd_queue_crypt
  crypt_endio

The same kmalloc(GFP_NOIO) is at drivers/md/dm-crypt.c:762 on 6.6.163
and at line 786 on 6.18.65.

Reproducer
==========

On Linux 6.6.163 #1 (KASAN, 2048 MB, 2 CPUs) the same warning printed
from ksoftirqd while it was running BLOCK_SOFTIRQ:

  BUG: scheduling while atomic: ksoftirqd/0/15/0x00000101
  schedule_timeout
  __alloc_pages_slowpath+0x13c0
  kmalloc
  crypt_iv_eboiv_gen+0x1ea/0x740
  crypt_convert
  kcryptd_crypt_read_convert
  blk_complete_reqs
  run_ksoftirqd

That offset is schedule_timeout_uninterruptible() in
__alloc_pages_may_oom() after mutex_trylock(&oom_lock) fails. The
program loads aes-cbc-eboiv with no_read_workqueue on a loop device,
mlocks 1100 MiB, and sets min_free_kbytes above MemFree so the eboiv
slab allocation enters the slow path. The OOM killer ran in the same
window and held oom_lock. The campaign hit is the other sleep in that
slow path, should_reclaim_retry(), on kblockd. Both sleep from
crypt_iv_eboiv_gen()'s GFP_NOIO allocation in softirq.

Yu Junzhe / FuzzAnything <fuzzanything@gmail.com>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-01  4:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  4:30 [BUG] dm-crypt: eboiv/elephant sleeps in softirq with no_read_workqueue Yu Junzhe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®