From patchwork Tue Dec 14 16:20:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12676403 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 12918C433F5 for ; Tue, 14 Dec 2021 16:40:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ABD66B00A3; Tue, 14 Dec 2021 11:23:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 45BBD6B00A4; Tue, 14 Dec 2021 11:23:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 324266B00A5; Tue, 14 Dec 2021 11:23:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 22F316B00A3 for ; Tue, 14 Dec 2021 11:23:36 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DB618181AEF09 for ; Tue, 14 Dec 2021 16:23:25 +0000 (UTC) X-FDA: 78916919970.17.7FF7CA6 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf09.hostedemail.com (Postfix) with ESMTP id C1ADB14000F for ; Tue, 14 Dec 2021 16:23:22 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id 187-20020a1c02c4000000b003335872db8dso11510646wmc.2 for ; Tue, 14 Dec 2021 08:23:25 -0800 (PST) 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=lDpTBNT0I1htzh1pdmjOA/Qp6nY6br0HXEMQd54phuU=; b=ArbC5Qlw/tWeRiWIZ1Y48jy30BP5Te592XfZpzZzD9zBlvepDTy+VQtTG21UxQ8inK yQOL5/iUYpmsTAyvZc8sQ9pumSl56H835fYEsQC9eio3bftA2y4TABqOc425Iji7rzD0 do7F/rEnnb+z0YaTwIqETnbFACe96SBPqBguZuj54fKEJhmlonknYdgCZJITPILp2O8R g/Ch0maZBcRaaUc1L/BUARrklla29VQPtw7qZiFG7IkzEUDEQh2/qgw8/gSMxyyP557X lu6CsOw225+EBUfCeJYIAFjyIdvEIiMwSAf2MXapEHMvfzu2rBKYIJpXiVaqCG5w0PwO hITg== 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=lDpTBNT0I1htzh1pdmjOA/Qp6nY6br0HXEMQd54phuU=; b=HtpgWP8v2F0nF0wIbbD8gPdSS+4UBruURC0ig6+gDbkxWKaXIgu0rBQIaUfRJNfnOZ yopIPEd9nGCQyoRSiCBxOGfTqtKwsKT17SAfcm339niLlFHt/TMCTvXgXkPBqKZX9FS0 bOO+Vr3vHKD0rvaKi7YWCyNpJQ3iVx783OSWpWep8q5Q39DR1BNB2JJPauGhpW8dBZql upLUrso4TlLByiQFA8GQVoYYZn8jBo5SBhlUkngSfe9DM2sTT2LTbIBwHeoEzTxy2Ni9 2kzodtGeZjmZI8qFelZiwxbtx+G0AcrlxZW287EKmdkvhZf21q7aePng2YakVl8DuayB E3ww== X-Gm-Message-State: AOAM533HL8O+7XM7RYTss+3wQdNzkkXG2VXnZgycl/jDq742uPmCOvg+ iFdzCDPrUGUexA/tM28/cN7K47IXakQ= X-Google-Smtp-Source: ABdhPJzd3+JglaYvwaWg/MkbkJuCDnCFW7n3Gc9z2XLMoLSMqx+inrD6O9GNKx7jFbb1Shu5Z94RjWGqmAw= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:357e:2b9d:5b13:a652]) (user=glider job=sendgmr) by 2002:a05:600c:1d1b:: with SMTP id l27mr5819855wms.1.1639499003427; Tue, 14 Dec 2021 08:23:23 -0800 (PST) Date: Tue, 14 Dec 2021 17:20:40 +0100 In-Reply-To: <20211214162050.660953-1-glider@google.com> Message-Id: <20211214162050.660953-34-glider@google.com> Mime-Version: 1.0 References: <20211214162050.660953-1-glider@google.com> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog Subject: [PATCH 33/43] kmsan: disable physical page merging in biovec From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , 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 , 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: rap9mygdmt7d1h3fji4rmqhcak41rg9y Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ArbC5Qlw; spf=pass (imf09.hostedemail.com: domain of 3-8S4YQYKCHwlqnijwlttlqj.htrqnsz2-rrp0fhp.twl@flex--glider.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3-8S4YQYKCHwlqnijwlttlqj.htrqnsz2-rrp0fhp.twl@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C1ADB14000F X-HE-Tag: 1639499002-48023 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 consequent physical pages may be inconsequent, 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 ccde6e6f17360..e0c62a5d5639e 100644 --- a/block/blk.h +++ b/block/blk.h @@ -103,6 +103,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 consequent physical pages may not work correctly under KMSAN + * if their metadata pages aren't consequent. 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))