From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03FD9C433FE for ; Tue, 18 Oct 2022 00:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbiJRA4P (ORCPT ); Mon, 17 Oct 2022 20:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiJRA4I (ORCPT ); Mon, 17 Oct 2022 20:56:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38C3656F; Mon, 17 Oct 2022 17:56:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D405EB81BF7; Tue, 18 Oct 2022 00:10:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6D8DC43470; Tue, 18 Oct 2022 00:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666051820; bh=g+WXfrzA4ISuTyVMiDVrnPZI2xkMfmlnL2F1oUbznow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quQWKCZ7T1/JqJKLKzhWbuhsJ2uwlmEBBESRo++VOSMytb3bEV3o8nnGG+YErxeCl NRhuhrt4RGA9OVQgzQjwACaQ63Qdfi0tn/KQhSb6nHDV+KCvyo4HBvOGG7f+7mw+S1 lhegizQHTyrE6b4rGflklPKCOGu3Nv71COkIjIPqmSQ9aerkVhV8VP9L1Rq2Cj9fdh KNG//5ddr8KsGYuEkb4gHcMwuQ9qTvw9+SqZHal2UHkxcUhwy+8PNQ+Qs3T/IRiUZs nsNasTynLfZVbCb3UR7UAvqufy6Lp4t9uDtvYVAxmisfCm4BjWdrvbiuVI2t2PfLik 61GONJzAGzonQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexander Potapenko , Alexander Viro , Alexei Starovoitov , Andrey Konovalov , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Biggers , Eric Biggers , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S . Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Stephen Rothwell , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , Andrew Morton , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 16/21] kmsan: disable physical page merging in biovec Date: Mon, 17 Oct 2022 20:09:35 -0400 Message-Id: <20221018000940.2731329-16-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018000940.2731329-1-sashal@kernel.org> References: <20221018000940.2731329-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Potapenko [ Upstream commit f630a5d0ca59a6e73b61e3f82c371dc230da99ff ] KMSAN metadata for adjacent physical pages may not be adjacent, therefore accessing such pages together may lead to metadata corruption. We disable merging pages in biovec to prevent such corruptions. Link: https://lkml.kernel.org/r/20220915150417.722975-28-glider@google.com Signed-off-by: Alexander Potapenko Cc: Alexander Viro Cc: Alexei Starovoitov Cc: Andrey Konovalov Cc: Andrey Konovalov Cc: Andy Lutomirski Cc: Arnd Bergmann Cc: Borislav Petkov Cc: Christoph Hellwig Cc: Christoph Lameter Cc: David Rientjes Cc: Dmitry Vyukov Cc: Eric Biggers Cc: Eric Biggers Cc: Eric Dumazet Cc: Greg Kroah-Hartman Cc: Herbert Xu Cc: Ilya Leoshkevich Cc: Ingo Molnar Cc: Jens Axboe Cc: Joonsoo Kim Cc: Kees Cook Cc: Marco Elver Cc: Mark Rutland Cc: Matthew Wilcox Cc: Michael S. Tsirkin Cc: Pekka Enberg Cc: Peter Zijlstra Cc: Petr Mladek Cc: Stephen Rothwell Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Vasily Gorbik Cc: Vegard Nossum Cc: Vlastimil Babka Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- block/blk.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/blk.h b/block/blk.h index aab72194d226..e833f606bf63 100644 --- a/block/blk.h +++ b/block/blk.h @@ -66,6 +66,13 @@ static inline bool biovec_phys_mergeable(struct request_queue *q, phys_addr_t addr1 = page_to_phys(vec1->bv_page) + vec1->bv_offset; phys_addr_t addr2 = page_to_phys(vec2->bv_page) + vec2->bv_offset; + /* + * Merging adjacent physical pages may not work correctly under KMSAN + * if their metadata pages aren't adjacent. Just disable merging. + */ + if (IS_ENABLED(CONFIG_KMSAN)) + return false; + if (addr1 + vec1->bv_len != addr2) return false; if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2->bv_page)) -- 2.35.1