From patchwork Tue Dec 14 16:20:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12676405 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 80D82C433FE for ; Tue, 14 Dec 2021 16:41:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE6BB6B00A5; Tue, 14 Dec 2021 11:23:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E9B0A6B00A7; Tue, 14 Dec 2021 11:23:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC1F66B00A6; Tue, 14 Dec 2021 11:23:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id B8E226B00A4 for ; Tue, 14 Dec 2021 11:23:38 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7D8D9180DD593 for ; Tue, 14 Dec 2021 16:23:28 +0000 (UTC) X-FDA: 78916920096.27.BE66B62 Received: from mail-lf1-f73.google.com (mail-lf1-f73.google.com [209.85.167.73]) by imf31.hostedemail.com (Postfix) with ESMTP id B39CE2000F for ; Tue, 14 Dec 2021 16:23:22 +0000 (UTC) Received: by mail-lf1-f73.google.com with SMTP id q13-20020a19f20d000000b0041fcb65b6c7so6759414lfh.8 for ; Tue, 14 Dec 2021 08:23:27 -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=hJREyaJODzN59ymWNpAGAfGc3N4tvevP8UF37PAE+J8=; b=oTH1LhNHOLMxItxiNi4P80arf3V90zcZ2D7XaYrMWD5zhzjnQGBBNtzXBtP3OTeZbR tREgkLUiMUgnBhnlpBEcb9spfWY/cnsLiVkZ4gM7i0ckihbSR9YkmKCgOjV9S1v24RC6 rcCk1732bioSUmVR0kALhf4VayHC/sBhWGQ0rYLrqC8INyjm10g/NTh+VCKjt5Ba9t+O Hb8n1v7nq8PZW0tTa5I8gF39PqqrSQOKemQDGVLB0z3T64pOPjyD2JlTfUJ0Bbh2pRjR 2uBonmx/fZ6h/wKPOVGIAJrZhtWwZfkkFYy/2mpCLi/sxNccIF40o59aaOuAx9Kf03c9 v5Zw== 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=hJREyaJODzN59ymWNpAGAfGc3N4tvevP8UF37PAE+J8=; b=eeS67btgZQ/NNjqNLb/nrZ67JrTzVe1kBnV8/kEQihh8q7GI6q52vwgZ6/9LNNk7Kd c8bJ5esFh1Fnb7qs5W1a1sEcfQRVqnK1cAMBJwjc+oDZ5kQ7nzlScJ1y7vmYTLpDABh1 f0n/xGf3X6tDpFRVuwooTPDKHU15OuwXzymxS2S3KkbSVXOJ0jH3Br9iDK6OXaG171vl 28YPx+5whiv0neAfWB9r5aGHT6SjT02+Xochd7L8p+ItLrrSkc/ReoHIH9WGgKbCISV1 1dJwKwRNHG49TIY3zlVspl2cSk4YTi4auRi9g3ChBq5+Fnw6WdNQRuBRCT1O6BmPdiJd j0rA== X-Gm-Message-State: AOAM530f7EZdY6TXognJ4PaGefxEQg1nCFl4JiNYw0gjtaxq0vNWgjRP 712A8XKgY03VWTnhZQrZU4soUmZER7A= X-Google-Smtp-Source: ABdhPJxXRu645cHJwsRfEAXihfv0Go5u7KwQ4UTJ1n3lO79v1JEfsX0lC2OS7GVAzadP34TGcewWINvNhMI= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:357e:2b9d:5b13:a652]) (user=glider job=sendgmr) by 2002:a05:6512:3991:: with SMTP id j17mr5582774lfu.545.1639499006493; Tue, 14 Dec 2021 08:23:26 -0800 (PST) Date: Tue, 14 Dec 2021 17:20:41 +0100 In-Reply-To: <20211214162050.660953-1-glider@google.com> Message-Id: <20211214162050.660953-35-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 34/43] 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 , 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, Eric Biggers X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B39CE2000F X-Stat-Signature: k9puy3oawtuy4a6ssr3z15ahjfc6mu8k Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=oTH1LhNH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf31.hostedemail.com: domain of 3_sS4YQYKCH8jolghujrrjoh.frpolqx0-ppnydfn.ruj@flex--glider.bounces.google.com designates 209.85.167.73 as permitted sender) smtp.mailfrom=3_sS4YQYKCH8jolghujrrjoh.frpolqx0-ppnydfn.ruj@flex--glider.bounces.google.com X-HE-Tag: 1639499002-246231 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 15ab0d6d1c06e..b94283463196d 100644 --- a/block/bio.c +++ b/block/bio.c @@ -805,6 +805,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);