From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC84211468; Thu, 13 Feb 2025 14:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739457972; cv=none; b=YAowjC66KHLntBz2XbLDDDA3Q0AoLyiiEl52a06u/Im34llhztjhSRbMBOA6NMTwtZTdihT/8MDzuAXPwcOsvuSYrBLqA9FZ8/Udj6rktwhH3WGaDXld/8dek+yZSX/Ys4E4c629g8WEGlHgKTaxyYJQq0VwXhXCmOmN7lF6bfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739457972; c=relaxed/simple; bh=N/sjQwCEPdxnKQus909jv7U/hSxNvT+66oQOe9lk3C8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iqUMXBflvj0pTLTVZfMMmZlVf2gdFLrSV06UxQoVlLQj476L+DVduf8OzRPmglNmWHM9j5U3igqoqPgJ9+yti6I2OMt+NEqhC4dxKo5oUxRXbUW1z0ibleDd6wNIMjrwDNVGnaszoFhHtD8aVefRfgubynmLwoU9TCjYQkAU+uI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=D/p/6XTt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="D/p/6XTt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C8E1C4CED1; Thu, 13 Feb 2025 14:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739457972; bh=N/sjQwCEPdxnKQus909jv7U/hSxNvT+66oQOe9lk3C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/p/6XTtH0JwsqAKzkD2Zk1g7vI/3He3t5QH/0iL+H0I51beJVnO9JQIxvJuLBEP/ ImfbJsQrYGqyuvXgt8E61i/W/VGrWn/MhoFQr0wrIayzhpcizQ4mx0NlhscLEenghn wSN+QRuO6CuHWci/7DkrklZ/VoXD9D7LZF5mH/bo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hou Tao , Mikulas Patocka Subject: [PATCH 6.12 233/422] dm-crypt: dont update io->sector after kcryptd_crypt_write_io_submit() Date: Thu, 13 Feb 2025 15:26:22 +0100 Message-ID: <20250213142445.527424332@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250213142436.408121546@linuxfoundation.org> References: <20250213142436.408121546@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hou Tao commit 9fdbbdbbc92b1474a87b89f8b964892a63734492 upstream. The updates of io->sector are the leftovers when dm-crypt allocated pages for partial write request. However, since commit cf2f1abfbd0db ("dm crypt: don't allocate pages for a partial request"), there is no partial request anymore. After the introduction of write request rb-tree, the updates of io->sectors may interfere the insertion procedure, because ->sectors of these write requests which have already been added in the rb-tree may be changed during the insertion of new write request. Fix it by removing these buggy updates of io->sectors. Considering these updates only effect the write request rb-tree, the commit which introduces the write request rb-tree is used as the fix tag. Fixes: b3c5fd305249 ("dm crypt: sort writes") Cc: stable@vger.kernel.org Signed-off-by: Hou Tao Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-crypt.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -2092,7 +2092,6 @@ static void kcryptd_crypt_write_continue struct crypt_config *cc = io->cc; struct convert_context *ctx = &io->ctx; int crypt_finished; - sector_t sector = io->sector; blk_status_t r; wait_for_completion(&ctx->restart); @@ -2109,10 +2108,8 @@ static void kcryptd_crypt_write_continue } /* Encryption was already finished, submit io now */ - if (crypt_finished) { + if (crypt_finished) kcryptd_crypt_write_io_submit(io, 0); - io->sector = sector; - } crypt_dec_pending(io); } @@ -2123,14 +2120,13 @@ static void kcryptd_crypt_write_convert( struct convert_context *ctx = &io->ctx; struct bio *clone; int crypt_finished; - sector_t sector = io->sector; blk_status_t r; /* * Prevent io from disappearing until this function completes. */ crypt_inc_pending(io); - crypt_convert_init(cc, ctx, NULL, io->base_bio, sector); + crypt_convert_init(cc, ctx, NULL, io->base_bio, io->sector); clone = crypt_alloc_buffer(io, io->base_bio->bi_iter.bi_size); if (unlikely(!clone)) { @@ -2147,8 +2143,6 @@ static void kcryptd_crypt_write_convert( io->ctx.iter_in = clone->bi_iter; } - sector += bio_sectors(clone); - crypt_inc_pending(io); r = crypt_convert(cc, ctx, test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags), true); @@ -2172,10 +2166,8 @@ static void kcryptd_crypt_write_convert( } /* Encryption was already finished, submit io now */ - if (crypt_finished) { + if (crypt_finished) kcryptd_crypt_write_io_submit(io, 0); - io->sector = sector; - } dec: crypt_dec_pending(io);