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=1796385607; b=EsBXVSwTo3VZkNMZGtne76w5Ok0hTNqEROsecBDm86JiIcTQxZPAAEHaftobOwAQGKVN eM4JIcUh5TbD8h35OULn0bED3c9QDaaGJLTJnfpUAYDLeFvvmwa6M8E/HlH4k6HITOKtG KrwDgAAwwaPlX+Xr4nWJ+IgG/Mi8j2cY7QELLXUMz+28kS1A9HIu2SILLil1i0dNN2n8j Jy5A4bhCE9hXZDO5qFmm+L8UWZ4hU8pLZUiSw0x3kojrMvC0WdnTTObChCokVJgRtnB0D 0R9zXXRoqLNAfo5C+rjgOdIZSTPyEcf9f1wdaFp0HwDgH2CsVrWDHqsDXTSY6iEUn6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385607; 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=g/5IagbyXQ8UmLxFfamD/ILdU7W8ovIrzriPzKB+r0M=; b=sq9CTc72XxJkVt0xLnN55ZbmmTmIpCkq8CsV01mokn54fXlxU12LTDHoyJSvxNUMBlma d8/XVBROIHRGS5GuQKWhxLcCn3pHkUCzyYtQwVyX2/nVBds3ZBxRGF4/9Ct62Wfo52aDZ HbjNpKibvv9L4ZVR7uTxqfPB1C2r30vP0SFNO2/uSth5Cer9iR/2txpwPxP7WTIV4RJ3L 1Oe2YgHw4TMvL9CnaA79DkfNIW72v2KxlJXMwR7F4U06jtwukwhLIgLvaaukLlaLrJcJR zBlJGyXzu8MjvR0nECp1hwiVusVpkuF1Mu66LYRxw6mU8T0pb/hKDzl8wXA8cRD80OQ== 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=UqGVbEq1; 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 4CAFB606A322; Fri, 4 Dec 2026 12:00:07 +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=UqGVbEq1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D84971F00897; Fri, 4 Dec 2026 12:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385607; bh=g/5IagbyXQ8UmLxFfamD/ILdU7W8ovIrzriPzKB+r0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UqGVbEq1TojitnrbhB5OuUrjEBSZx/K+yDnC+HfpYP5VXOVxdL3xkdriz9i9amDjv FuKF2yzaAo7EwyQv/M3OmVyfakji3L1t9U5/59rQPyWtR9FMGIXumxCuQCUTS5vqrJ ko8mnk5lzOpB7EdzJwOcdDw2wnECWl9snW59SnWQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Schlehofer , Mikulas Patocka Subject: [PATCH 6.6 0617/1167] dm-crypt: defer async write submission to write thread Date: Fri, 4 Dec 2026 19:00:44 +0900 Message-ID: <20261204100718.141038572@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 @@ -2017,8 +2017,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; }