From patchwork Wed Mar 25 16:12:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11458301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 711E615AB for ; Wed, 25 Mar 2020 16:15:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3EB4320409 for ; Wed, 25 Mar 2020 16:15:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iYsVbAfg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3EB4320409 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8B6416B00B0; Wed, 25 Mar 2020 12:14:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 866726B00B2; Wed, 25 Mar 2020 12:14:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7565B6B00B3; Wed, 25 Mar 2020 12:14:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 4D4B86B00B0 for ; Wed, 25 Mar 2020 12:14:48 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 37E42180374B0 for ; Wed, 25 Mar 2020 16:14:48 +0000 (UTC) X-FDA: 76634383056.29.spark49_8135f47a1ee19 X-Spam-Summary: 2,0,0,75f4eca94ea582fc,d41d8cd98f00b204,3d4n7xgykcgykpmhivksskpi.gsqpmryb-qqozego.svk@flex--glider.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3152:3352:3866:3867:3870:4321:5007:6261:6653:6742:6743:7903:9969:10004:10400:11026:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13069:13161:13229:13311:13357:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:21740:21990:30054:30064:30090,0,RBL:209.85.222.202:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: spark49_8135f47a1ee19 X-Filterd-Recvd-Size: 5140 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 16:14:47 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id c130so2045216qke.20 for ; Wed, 25 Mar 2020 09:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=6Dc/WULxB95F3AB5gER5EcyE/qW7aJyrm6XU3/Fe0ro=; b=iYsVbAfg0lt2SyLUIaY5uUSMBD9BtWBDka8NRqG3vhp+T2imnNK3ZvaJMyoJzZjTe2 gAQ+2fy02Fc260dUv8Ju788jqzU6wHyk0d+tUF2+LVImcqlP/rlhZohtdznRCDuwsIQZ pVL0d+TCyn1xvD/QJ9+7/Ezsp+d0E8/qJP6xyHoM8/caTPlErGZ7GJi5DSrukjxTfNYx rNbbNULqOCp3mZ2ECR/tO6W1eNdmpsp5zkB0uyG4M0xBQumvij9/fUImJxSX067gtYuJ 0YzSh1PxX565KfgEvqsISgywqtlZuGpklpzE9xiTw8PQxDX146nhniuxI6dg08lptWzF gKuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=6Dc/WULxB95F3AB5gER5EcyE/qW7aJyrm6XU3/Fe0ro=; b=fI0F5M/NOj3ovzkQzsP/xkiLnNie8RpRYfOPH2G83tm4NnD8t8jmsWimFmghexXWKX qLJ4B/xqn98VxJO6WjStU9Fy3rJ48kjRs82SD1UujmIwLZFCy7BIyRP0leFw6KD1eV5B eBZ9/2a5TkFagkU9ORjk0zzbvCX6fZYMzL8A8p/XCxl2Mz72Czgki1hktTdEctGWTS4h IXZcduJSLOFEdV77LjyL6jp89S1Fby7Ww/QJ1cArem5NkLKN+k9miA1TfxzLMqJkQeM3 VnwLZGaCFKUXrh7aF94hNSTWS3KAU3OIB7pexds62ot/viRARL80ukblvH/iOg6ywhZC NjGw== X-Gm-Message-State: ANhLgQ1c7daxdoSXDhciQS2Sv+LH5q43mM2Tpn+U7vxPKxHbH/LzM+RS iLPA4atCvbWqlG1boXvt1XmprVFbxDg= X-Google-Smtp-Source: ADFU+vtEwPD0FGW2eyPUiVqUaE0MiMd6oaoua7tt4VM50bjR39X5IxrbKJRRL0TJ4FV77mI3ir6HR9qgHT8= X-Received: by 2002:a0c:fe87:: with SMTP id d7mr2825777qvs.37.1585152887001; Wed, 25 Mar 2020 09:14:47 -0700 (PDT) Date: Wed, 25 Mar 2020 17:12:46 +0100 In-Reply-To: <20200325161249.55095-1-glider@google.com> Message-Id: <20200325161249.55095-36-glider@google.com> Mime-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v5 35/38] kmsan: disable physical page merging in biovec From: glider@google.com To: Jens Axboe , Andy Lutomirski , Vegard Nossum , Dmitry Vyukov , Marco Elver , Andrey Konovalov , Christoph Hellwig , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, aryabinin@virtuozzo.com, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, m.szyprowski@samsung.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, mhocko@suse.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de 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 To: Alexander Potapenko Cc: Jens Axboe Cc: Andy Lutomirski Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Marco Elver Cc: Andrey Konovalov Cc: Christoph Hellwig Cc: linux-mm@kvack.org --- v4: - use IS_ENABLED instead of #ifdef (as requested by Marco Elver) Change-Id: Id2f2babaf662ac44675c4f2790f4a80ddc328fa7 --- block/blk.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/blk.h b/block/blk.h index 670337b7cfa0d..065dfee244118 100644 --- a/block/blk.h +++ b/block/blk.h @@ -79,6 +79,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))