From patchwork Thu Sep 15 15:04:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12977545 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 F1521ECAAA1 for ; Thu, 15 Sep 2022 15:05:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8716480011; Thu, 15 Sep 2022 11:05:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8478280007; Thu, 15 Sep 2022 11:05:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7100280011; Thu, 15 Sep 2022 11:05:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5E87B80007 for ; Thu, 15 Sep 2022 11:05:54 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 23FAE160381 for ; Thu, 15 Sep 2022 15:05:54 +0000 (UTC) X-FDA: 79914644628.18.CB56BB2 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf19.hostedemail.com (Postfix) with ESMTP id 737EB1A008F for ; Thu, 15 Sep 2022 15:05:53 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id gv43-20020a1709072beb00b0077c3f58a03eso5566770ejc.4 for ; Thu, 15 Sep 2022 08:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=T4yulc1U4RDI/lAlxqlpzG4AIUYO9fQrzg+B84ydySw=; b=bjU5Y1Uj6lzmlmNdbvfJIhixfGz/+MKGRYCvur483Xf78D7CTzrNFlvd42wNziHYle Vw8zzRUPc25b8rF96my1wPCxCLp6TfupI3RftJKXAn7dq2QlPkGvBgmhor+As+69qJvo ts7cyW+lzlkiH21NDXMKOi08blf2XU9uBJs1YmQtKDbV3CYIcVN2LJH0wP7yDNAqAidw 2NVtGckV24urbHpg+UiXfOqAjGlT6CwNPdgB8y3HFou9URtWV43Pi53vkh8E0/1cN/xT J7/cYcC0yfDbDZhb+v1n2EFZPIQNAXrNcvBidelmwV20Zr+dNqjJnJC6KZ8B/YMPJfPN pmuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=T4yulc1U4RDI/lAlxqlpzG4AIUYO9fQrzg+B84ydySw=; b=RtIOl2Rl2r1a5jCDTa1une38hvYihRlVBaf/ueurBQKYHxLlAcu8t0znQJD8y+HjbZ cSuiXOUbZHIN6tsUCY9Vg4Aal4EC6BsWt2bz/WVUMbv793fKywoS+3IrgJMASNqbs7l8 DLrCwb9XiLF2qJiDLgqHc5g95DbV1Dg0o9DRUgWYYsAUjBEGL7DRLeIOc2Gj2Fu+SrLP FHA48OlXitz9q/h7CXzVhEnl6O8Q3L2vIWh0OAcaFGxolBlTWmXtZ5Mu8LKB/DElelML gO6Yo5HbVaohqMi1y7eMn/e/6qILrsw0YSttCUfi3xdyiKeZT2sXbLKbPU8oTuWOXbqq bmiA== X-Gm-Message-State: ACrzQf1O06JuHyg2AEADhZ9RcXyS5V3Y3tTTC3Ax51HCT03Qx4VRS775 xIaxGlWLOohGltHR0QU0v4M4xg1sAT8= X-Google-Smtp-Source: AMsMyM7l8lWYGJuBODDQ/HU6R5pl1eaYbgBKHbyvWwWvFjThOz32FII2oCbiswhP6heZLHjrzuBd6Y58nd4= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:686d:27b5:495:85b7]) (user=glider job=sendgmr) by 2002:a05:6402:d06:b0:440:3e9d:77d with SMTP id eb6-20020a0564020d0600b004403e9d077dmr260579edb.286.1663254352056; Thu, 15 Sep 2022 08:05:52 -0700 (PDT) Date: Thu, 15 Sep 2022 17:04:01 +0200 In-Reply-To: <20220915150417.722975-1-glider@google.com> Mime-Version: 1.0 References: <20220915150417.722975-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220915150417.722975-28-glider@google.com> Subject: [PATCH v7 27/43] kmsan: disable physical page merging in biovec From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , 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 , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663254353; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=T4yulc1U4RDI/lAlxqlpzG4AIUYO9fQrzg+B84ydySw=; b=686GdvxVe3a9AzUQyyjIx6LGQJvemXunun7mFlw+0HcPIP1pbDBAYckH5RP23cUxyaHosx VXMPjjnJ/K/e4Dep4DyWDgi0HqqPZWl07RcYJYEKkGAbHlHj4j09m71ADkHd0BsN+wb0QK LG3GM40VA2EzVjfR392CMdn/JOJxT74= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=bjU5Y1Uj; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of 3UD8jYwYKCHsfkhcdqfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3UD8jYwYKCHsfkhcdqfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--glider.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663254353; a=rsa-sha256; cv=none; b=GWWmqtoirekDTaTjcG2HqDQgXdBqldO9cSTaC4frKvkifxguZbVGYy+OrjdMb+EhtHtKqB 7gLXDpYpPBHu3qRDs6TpXO3+LUIXLO3wS3RL9DL4/XoDTjlmwc7zgL8qTaH1mwY15XUoUx iIyyUYj72nJJF2fahfNt90z+qQgl6LI= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 737EB1A008F X-Rspam-User: X-Stat-Signature: 6czqigoyc8q83cujcdzmhnj4nfzojtpd Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=bjU5Y1Uj; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of 3UD8jYwYKCHsfkhcdqfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3UD8jYwYKCHsfkhcdqfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--glider.bounces.google.com X-HE-Tag: 1663254353-284594 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 d7142c4d2fefb..af02b93c1dba5 100644 --- a/block/blk.h +++ b/block/blk.h @@ -88,6 +88,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))