From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388332; b=oYfM1mcVitgZpvQETvsC6jTOLQzlK05OjsgpmlPvwzBv0I9ORDHXqCUvJKlojU+uVLa5 hGpiLoEHbPNf1Gm/IiGVik6C1NRnYYqb3A7wsecHSBNPdZDcj5ybybniW4kojaR7Wd6EL gsLa0t5StNawZQhBn9lLpD5eYZMvyNdPmdQ/5Aq8pKG4aapD7I6IQQGZi1u1kENPrhpYx YTks5iFHdZqRrvLoVI3rievQrIxRYEEK+ncOMMrlrpvTjtzb1SmMOJp1ker5CRqLgL9wc 5RkVhz2rr5BXmYSI+ATPaby0KfLPPFLQZXLL70pxaCxxWmHpv+3Bgi2BPXCuDebF3jg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388332; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=RBRTwjxGztPQ3w3kVE2voZep/O6N5lFTluSdaWxW6rI=; b=5YWP0ZBGJzGUHSss9TOTF1GO08lyAzmD6DWXmU/Wa11XojL+EkD/dAbNZ1TGIsG9j14E I0MO7jLr45mRXwanQliWWwyFFwbpTHfmT2/pLd2SisTHYZAoiUHWMjPe7WXykfjVEHO/7 HYjji/QxVjyBf1Wsg2+fVp0jamH0LaDxAxHqTKdbJtyXrrlrg1ytlV4uf4/4rb2bujti4 bPxOapGM1XS+aBEoFS585WbY5qEsjAfPeMPy8msshmkuzvmFPfXYs1YsuXpNYXm6+crgz Xg9iEycFdPf4es0Nmh5zS2UkAblX5Y7EKligOlMT/ECTQD23b+tulhrK7VX706gIAfQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JrCMrKH3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F1AC606A322; Fri, 4 Dec 2026 12:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JrCMrKH3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21B261F00897; Fri, 4 Dec 2026 12:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388331; bh=RBRTwjxGztPQ3w3kVE2voZep/O6N5lFTluSdaWxW6rI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JrCMrKH3vyY9muaDN3ov9/7D1bxB3E5nVJbIUjnfNHBZXgnPeoIsSpMa+K/iGTGMv wOlJ6xbu54PkhwlawJwAbOjkqYzi8x4Nw4zLv6y4nJOnxZcshk5nl/58J9v5/tGGR9 8s/NOVAh1QRWwUzL/Ws3VnxnV7ahRlrYOtrM8Zio= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Schlehofer , Mikulas Patocka Subject: [PATCH 6.1 0573/1059] dm-crypt: defer async write submission to write thread Date: Fri, 4 Dec 2026 19:01:44 +0900 Message-ID: <20261204100659.011282002@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Schlehofer commit 6fed9e26810f0b466dbcebe35a73d1fd48793ff5 upstream. With no_write_workqueue, kcryptd_crypt_write_io_submit() submits the bio directly, even when called from kcryptd_async_done(). An async cipher may run this callback in softirq or with BH disabled, where submit_bio_noacct() must not be called because it can sleep. Submit inline only when async is false. Async completions are sent to the write thread, as is already done for submit_from_crypt_cpus. Use the async flag rather than in_interrupt(), since callback context depends on the cipher driver. Sync ciphers still submit inline. Tested with cryptd in QEMU (x86_64 and arm64) with CONFIG_DEBUG_ATOMIC_SLEEP, and on a P2020 running 6.18.55 without it. In QEMU: - 4k writes logging "sleeping function called from invalid context": 100/100 unpatched, 0/155 patched. - nr_requests=4 on a loop device: 0/6 unpatched runs completed, 4/4 patched runs completed. On the P2020, a warning in blk_mq_run_hw_queue() appeared in the 6th unpatched run and did not appear in 30 patched runs. Fixes: 39d42fa96ba1 ("dm crypt: add flags to optionally bypass kcryptd workqueues") Cc: stable@vger.kernel.org Signed-off-by: Josef Schlehofer Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-crypt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1981,8 +1981,9 @@ static void kcryptd_crypt_write_io_submi clone->bi_iter.bi_sector = cc->start + io->sector; - if ((likely(!async) && test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags)) || - test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags)) { + if (likely(!async) && + (test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags) || + test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags))) { dm_submit_bio_remap(io->base_bio, clone); return; }