From patchwork Tue Mar 29 12:40:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12794784 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56646C433FE for ; Tue, 29 Mar 2022 12:42:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCD848D0017; Tue, 29 Mar 2022 08:42:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D565E8D0016; Tue, 29 Mar 2022 08:42:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1E2E8D0017; Tue, 29 Mar 2022 08:42:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id B21418D0016 for ; Tue, 29 Mar 2022 08:42:02 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7122F1828A44C for ; Tue, 29 Mar 2022 12:42:02 +0000 (UTC) X-FDA: 79297386084.23.D34027C Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf10.hostedemail.com (Postfix) with ESMTP id EA86CC000B for ; Tue, 29 Mar 2022 12:42:01 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id x2-20020a1709065ac200b006d9b316257fso8150218ejs.12 for ; Tue, 29 Mar 2022 05:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=g4O/g3yGtjFTnRq6Tym+8EhZXJHjgp/RAJrohmerxSE=; b=qOFgBTIRaBAgytLmSPVdMFIKWup6qEgqCTL9zlLnfBr+1qisKGAs7mZQzS5fF1N0/w 75BSqMadVv+ZwN4R/Y1880VwCu1sYPXecdfh1+jci1QJBCu4bN2ZpoxrkGg5fNAeuw4/ uqe7fS8vFdcz0MK3boRrEmswcahRoIs30mkNDrxgpAlwqh22khuALzbXXL7Bb57cf0og bNlPI0uZOKQd1VXKE1IEuIH6YQWnxA8v5sTwzz+4zJH90L3gpVOfXta50Pkpjz1H1DCt 0Gsp0BrH+su3tpLOFauLfvXBA1RwcNoUCkd+jh5ebsHf0jr1Db/zRDrg1iivqcmqkSXF Zf4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=g4O/g3yGtjFTnRq6Tym+8EhZXJHjgp/RAJrohmerxSE=; b=EXPtw7VUeOU6ju1WUnPRWtbg1OI+EySmaxxj3gKb8xRXZmNNC6oEfvBeF5DXl4YuwS cnZ/ulXG6KX1lJ+OvnvxbZusacIXU1EPZNBjSqzs2HKbJK+7G7nLXEwR5+A2VtHW7rO+ KlD2cHZQ1xI1sASufB4DcMqjfT7/jtiXJwMYsuUCb0Z79+I9a3JqDoQQrs/n+uCgrvxu j1SgSQCOoCC62uxs/OgDTsS1D+iMnXdLnLZ+KtVU9TpqjQwM62zMX6dvWDozcr40AzbU +omJuXTEZlPVrMd3fXvscbGJGpK293ZrPl7owUkSp10SYuGsoVbxOsyfLWaqrj46PvB8 6ZlQ== X-Gm-Message-State: AOAM532Dg3ZIBMUAbz2CAC3WfvqvIgisUs/gWhB5t9FAr9+/yNYTnzV8 24/3gfORmDi301vc+x2N+T7Z1QtZKBo= X-Google-Smtp-Source: ABdhPJxPAPS1bh/Xpqng2jeIO39gOYiCpSBLkakMLcyM6oP3/B0k9R3pYWtakO+RdreM9L/Qpt7ZGcmIJWk= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:907:da6:b0:6e0:c59:f3ad with SMTP id go38-20020a1709070da600b006e00c59f3admr34366333ejc.85.1648557720656; Tue, 29 Mar 2022 05:42:00 -0700 (PDT) Date: Tue, 29 Mar 2022 14:40:03 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-35-glider@google.com> Mime-Version: 1.0 References: <20220329124017.737571-1-glider@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH v2 34/48] kmsan: disable physical page merging in biovec From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , 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 , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org X-Stat-Signature: mnx9hfptee4xpgdirpb8j3fy1uu3bicb Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qOFgBTIR; spf=pass (imf10.hostedemail.com: domain of 3mP5CYgYKCLkfkhcdqfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3mP5CYgYKCLkfkhcdqfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EA86CC000B X-HE-Tag: 1648557721-439362 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Signed-off-by: Alexander Potapenko --- Link: https://linux-review.googlesource.com/id/Iece16041be5ee47904fbc98121b105e5be5fea5c --- block/blk.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/blk.h b/block/blk.h index 8bd43b3ad33d5..eb349916ac116 100644 --- a/block/blk.h +++ b/block/blk.h @@ -93,6 +93,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))