From: Yu Junzhe <junzheyu1@gmail.com>
To: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [BUG] dm-crypt: eboiv/elephant sleeps in softirq with no_read_workqueue
Date: Tue, 1 Dec 2026 04:30:01 +0000 [thread overview]
Message-ID: <20261201043001.269-1-junzheyu1@gmail.com> (raw)
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>
reply other threads:[~2026-12-01 4:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201043001.269-1-junzheyu1@gmail.com \
--to=junzheyu1@gmail.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@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
all inboxes | Powered by JetHome®