From patchwork Tue Mar 29 12:40:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12794785 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 E740BC433EF for ; Tue, 29 Mar 2022 12:42:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 803858D0014; Tue, 29 Mar 2022 08:42:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B27E8D0002; Tue, 29 Mar 2022 08:42:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6515E8D0014; Tue, 29 Mar 2022 08:42:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 58D2C8D0002 for ; Tue, 29 Mar 2022 08:42:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1C7848248D52 for ; Tue, 29 Mar 2022 12:42:05 +0000 (UTC) X-FDA: 79297386210.29.30F4472 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf03.hostedemail.com (Postfix) with ESMTP id 8E9792000C for ; Tue, 29 Mar 2022 12:42:04 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id de52-20020a1709069bf400b006dffb966922so8125421ejc.2 for ; Tue, 29 Mar 2022 05:42:04 -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=/KmrLQz2B9LUGG5T0s5DB1smaxsYg6k7avQ3Zjj3eGk=; b=nf15GMhub2RWppTwCYZIrWIlhESGQRfc/W+NIYyqHWkrAY5ZTdWS9tNg5R+WFNEwDR ws+bWlr0jAPjLQgTU8HBYWK/xBDV/+Z4gS8/E0xP18HFUtngLfocVvFSvgaAAKlkp4H3 kXATs/dpgLrmitCYFBWHPxmJvSrUCCPUNzG/KXTkCq2AyohIUvlifgXGdxppP4apBE5A LAliLdtfENt0IXvOlwHuX/jsHQwOwjSPAiUrAj6DAH7RdyI9h/hc7xkf9IhqtKQUhdA7 KWoj2cicXsXsWzrnFpLIgQlZXdwXJns/c+61ORU+3rxi9tyOWn8w7u20i5xnvlynULyv A3iw== 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=/KmrLQz2B9LUGG5T0s5DB1smaxsYg6k7avQ3Zjj3eGk=; b=0D5N7MoR7k3XDvIajRgddh+a/qZ35JcDNcv1049UoYN/QAPffntguHWz8VtIB0rKfW 17Ys+6JywnCp5cLcaR2WEl+YAIllK++H4VqBvhiknIqYz+5lJmxvlAMOoml669hpyxrq aZADszHPoRqhU91eXOq6WuhxIjOYcfM5iE1uGVKBitGejmccFxBpmd5pNjK21G1b93hx yjooLabli3hlIXNN/pweB2aCI++eXZzCtR0QbgaaS7S+bcnyq5GBljr9WroEMuWOLGfP 2hr+y8yeeSh+vbRvfhy9UvJNFj06V/Vy9OoCE9McBmCm6sX5xBLZBV/+xZutyds4dlu0 952A== X-Gm-Message-State: AOAM531Kc3YfVV7Img/SQRONeIT4Ym07lvpl8aJSF6Y3TRKFnxgw3BRm YLsiXpPJUqxmr+BEUggM7YNsKVK2DTo= X-Google-Smtp-Source: ABdhPJxVb0eTOD5/UioVaLlWvIUvUDI3ZO47Rl6mwf+HN91ZLWrwoGAWiWD7v0UD4gilbb/v2zNMV7AgqQo= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:906:3583:b0:6d1:c07:fac0 with SMTP id o3-20020a170906358300b006d10c07fac0mr34312763ejb.749.1648557723241; Tue, 29 Mar 2022 05:42:03 -0700 (PDT) Date: Tue, 29 Mar 2022 14:40:04 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-36-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 35/48] kmsan: block: skip bio block merging logic for KMSAN 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, Eric Biggers X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8E9792000C X-Stat-Signature: 3do8sxtogfdph4hpoa6xoxz4e1t1hpj5 X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=nf15GMhu; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3m_5CYgYKCLwinkfgtiqqing.eqonkpwz-oomxcem.qti@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3m_5CYgYKCLwinkfgtiqqing.eqonkpwz-oomxcem.qti@flex--glider.bounces.google.com X-HE-Tag: 1648557724-754779 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 doesn't allow treating adjacent memory pages as such, if they were allocated by different alloc_pages() calls. The block layer however does so: adjacent pages end up being used together. To prevent this, make page_is_mergeable() return false under KMSAN. Suggested-by: Eric Biggers Signed-off-by: Alexander Potapenko --- Link: https://linux-review.googlesource.com/id/Ie29cc2464c70032347c32ab2a22e1e7a0b37b905 --- block/bio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/bio.c b/block/bio.c index 4312a8085396b..3c8806bbe3a81 100644 --- a/block/bio.c +++ b/block/bio.c @@ -808,6 +808,8 @@ static inline bool page_is_mergeable(const struct bio_vec *bv, return false; *same_page = ((vec_end_addr & PAGE_MASK) == page_addr); + if (!*same_page && IS_ENABLED(CONFIG_KMSAN)) + return false; if (*same_page) return true; return (bv->bv_page + bv_end / PAGE_SIZE) == (page + off / PAGE_SIZE);