From patchwork Fri Jul 1 14:22:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12903386 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 C592FC433EF for ; Fri, 1 Jul 2022 14:24:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FA4B6B0082; Fri, 1 Jul 2022 10:24:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D1436B0083; Fri, 1 Jul 2022 10:24:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 471906B0085; Fri, 1 Jul 2022 10:24:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 35D306B0082 for ; Fri, 1 Jul 2022 10:24:38 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F2A6B967 for ; Fri, 1 Jul 2022 14:24:37 +0000 (UTC) X-FDA: 79638751794.20.E4D6D55 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf28.hostedemail.com (Postfix) with ESMTP id 911BBC004A for ; Fri, 1 Jul 2022 14:24:37 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id x2-20020a1709065ac200b006d9b316257fso840605ejs.12 for ; Fri, 01 Jul 2022 07:24:37 -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=ssAyKoViePAlR4LG6grDIIfDn5PGY84PY+YiOkKWqdU=; b=G6KzvVOzqo6QJFZMWm6nHQe5vJR+zroKwVscg+jN/JKqdskPZJ/1aqhWFYtC+2bwxo NXP1bfPuLlXUIIgvbs9p8xHqK+UMJ7rwAgUxvQozkeEjqAnLE/RFvNQVwvJnt+81yd+v HpfzN1hhNUR3zRliOOqHbAvewRvY5bCwm21yXKVpqWRCePcOpIkqnSd6sMD2Wkw4/xTQ KhUqVjXvWdacoQCUWPYOlEcJPWnDk+z27yXN8YpIbfxkOh5QZGnMGQLocZsfvItYsGD6 QbDu599Ew6o6dwINWsW0S8a6FHYXse2CJVkRD/6pUzIL5NVKDDIcBkPGOvIc1AplaBNk xrxQ== 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=ssAyKoViePAlR4LG6grDIIfDn5PGY84PY+YiOkKWqdU=; b=d5turYzM4qmiSGp/0vgCqR/gZqIgjyXhxNNuOOyAPiW/v6LH2tFhYEmSm2cSNw27hg WlqDhoD7mp2KCYD1/2XCULxk4W0kl+zfjUsoV2AmKpdxAUEFrKlyDnLBLpt+TloPUEPA DxZMDWodJpIVJpcVTwlZoeYqKTHm83GM04Q+0k64UnEBIPLPA7ztwAwD4COG/CmEGNP6 6EzzxtbH7xYVGf2RpjCWkL1K8Sx1akzkIAffVCAsnfymTlQN8t9WP41gLMXigbosFv8n JH+oPr/vLU56L6jKmTcMje6vGMTUvvcMZ9DdM1C/ks9/P57xpuqqV5j6iYoBBFC3MSRp zWrA== X-Gm-Message-State: AJIora/Brv4Rx7t5SwE0zXWIa1OiK2LQMMzCvgIBdUI7qxhA3RDZGwP7 KxJegzMK96E9QYj1w+SD7UGAHRydRDE= X-Google-Smtp-Source: AGRyM1tVCF+sV/LeuqKsrQABp8XqaJxrk3E/8bbS/UOAygvrbBIURmws57k41Fha3AzhybLg/iCTnOg5f0Y= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:a6f5:f713:759c:abb6]) (user=glider job=sendgmr) by 2002:a05:6402:2077:b0:435:a428:76e4 with SMTP id bd23-20020a056402207700b00435a42876e4mr19161928edb.367.1656685476397; Fri, 01 Jul 2022 07:24:36 -0700 (PDT) Date: Fri, 1 Jul 2022 16:22:54 +0200 In-Reply-To: <20220701142310.2188015-1-glider@google.com> Message-Id: <20220701142310.2188015-30-glider@google.com> Mime-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v4 29/45] block: kmsan: skip bio block merging logic for KMSAN 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 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 , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Biggers ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656685477; a=rsa-sha256; cv=none; b=jjIFuWcdeg6zGrQLum/6rcVrGpPrMXfktcotkqxCeGNrN/B8FyW32XoJ38LrxSWW1WxSgl BpHJCJ/5uk/gMzb+a8PVI/2hLUTWEhoWzN1/XiVH6jiOOoPTz9ItHMt91znJoPCFNV+iFr j0H601PA5UZkaMdnatWLKQcfQJLz680= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=G6KzvVOz; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3pAO_YgYKCMMpurmn0pxxpun.lxvurw36-vvt4jlt.x0p@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3pAO_YgYKCMMpurmn0pxxpun.lxvurw36-vvt4jlt.x0p@flex--glider.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656685477; 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=ssAyKoViePAlR4LG6grDIIfDn5PGY84PY+YiOkKWqdU=; b=k9tHqmGDEmnokMIXIXMUivx2zbCFgJmBObmWjpRZnB1vA3fptiwXDdhRi6eAMqQvZuBpME YFVWX1/RbDd826jW+NXyZbmnnYZQ1WyASv6IuX+ucGKjGRRgnA7ej99C39DMgRCwgOvhN0 xEoJnj4wrKCplTMIWYEPjUmEE4Dxq8M= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 911BBC004A Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=G6KzvVOz; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3pAO_YgYKCMMpurmn0pxxpun.lxvurw36-vvt4jlt.x0p@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3pAO_YgYKCMMpurmn0pxxpun.lxvurw36-vvt4jlt.x0p@flex--glider.bounces.google.com X-Rspam-User: X-Stat-Signature: 19ejg368354uj3ixg9y9jem3cz9w3sps X-HE-Tag: 1656685477-183631 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 --- v4: -- swap block: and kmsan: in the subject 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 51c99f2c5c908..ce6b3c82159a6 100644 --- a/block/bio.c +++ b/block/bio.c @@ -867,6 +867,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);