From patchwork Fri Nov 22 11:26:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257927 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 7F68014DB for ; Fri, 22 Nov 2019 11:28:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A2D32070E for ; Fri, 22 Nov 2019 11:28:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="h1NpNatY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A2D32070E 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 24B126B0503; Fri, 22 Nov 2019 06:28:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1FA496B0505; Fri, 22 Nov 2019 06:28:17 -0500 (EST) 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 0C2C36B0506; Fri, 22 Nov 2019 06:28:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id EB6DA6B0503 for ; Fri, 22 Nov 2019 06:28:16 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id ACEBB8249980 for ; Fri, 22 Nov 2019 11:28:16 +0000 (UTC) X-FDA: 76183689792.20.trees03_e06d63074f2c X-Spam-Summary: 2,0,0,ca1dcfc93fe643cc,d41d8cd98f00b204,3t8bxxqykcdasxupqdsaasxq.oayxuzgj-yywhmow.ads@flex--glider.bounces.google.com,:tytso@mit.edu:adilger.kernel@dilger.ca:vegard.nossum@oracle.com:dvyukov@google.com::glider@google.com:viro@zeniv.linux.org.uk:akpm@linux-foundation.org:andreyknvl@google.com:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@infradead.org:hch@lst.de: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:axboe@kernel.dk:m.szyprowski@samsung.com:elver@google.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.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 :tglx@li X-HE-Tag: trees03_e06d63074f2c X-Filterd-Recvd-Size: 5105 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:28:16 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id w5so4467066qvp.13 for ; Fri, 22 Nov 2019 03:28:16 -0800 (PST) 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=kSPS59nR1EAFDegHXqn4xqIJVnU3Utla5R80fWuIcGI=; b=h1NpNatYpS+rwIHht0Mki6IzDOOA2w8pG02f/MBnrXTSvY6dpmC/gGB69vfg/xXY4p UBBJ9cVIrkmGEOaa/clXmzyjK8qwoCP17ZBGDAwOpWDlLmEQQUvY1Fr5jjkLbC/LKcHA SRcZvydh5CVTEHVUusOMIHB8DwMLvos2/WDzlV7Zcw4QX+zNwcThhOfe1wDstelE/f57 o25Fc7Sewo8nFtZ5t7W0ZCTTfH1fCp/M6KxGx4mtulnKsd8OMMZZcNpJDIdAVQ3Ig1xm HFC7ks9TvyfMxMms+48/qlffGHlOTe/x8IOnVPYTpuQjc/KnP5ba+IPKCSO5gVrVKQqU iqXQ== 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=kSPS59nR1EAFDegHXqn4xqIJVnU3Utla5R80fWuIcGI=; b=d/AxbiL00MhGPLngD0+G5sxq3xjg+FEHEK/kPN+TyI2nuHO2ZmT0JNH1WoUx70SqiQ Wxd4HzHrkvGiWdgtQSy2CiYU3+YiNCpTOoFxbfLzU7FExKYM4fBs+C3+eclucypFenj2 cSFjsqgF0yg/SlYX8BapMNbIU/x+dFAnmyEYRy3ORxjOFg4+XZLWOAJl392pdjj69Oij OCsnM+MB7JR/jIs+lxyncOIirzgpvE/akqJD2Y/Z4eKnF0K6l0DLaC/Fa3KepoqOgjKl EaLa9TErPkCsNcOUZGn3cmZLY0s2l6/9y0I1AiLXDllpzSEd9v9Db/HVexoGK76xyznS BmrQ== X-Gm-Message-State: APjAAAUJH66RP20uCELRtoLNa24i6mHBfEGQVUuwdk0T6rY1YRs4DezS gx212JlFth+XuX9pGfn8a1nnNUqMUh8= X-Google-Smtp-Source: APXvYqwTxJei3hfil3BMb+m8vtFTBg9vTst8TwzMlTqPhy3trTkpZ2IDyuZGoVkY3ZcYd2I5Wgrm4WNwjYM= X-Received: by 2002:a37:9b50:: with SMTP id d77mr12992032qke.349.1574422095516; Fri, 22 Nov 2019 03:28:15 -0800 (PST) Date: Fri, 22 Nov 2019 12:26:20 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-36-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 35/36] kmsan: ext4: skip block merging logic in ext4_mpage_readpages for KMSAN From: glider@google.com To: "Theodore Ts'o" , Andreas Dilger , Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, andreyknvl@google.com, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, hch@lst.de, 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, axboe@kernel.dk, m.szyprowski@samsung.com, elver@google.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.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, 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 doesn't allow treating adjacent memory pages as such, if they were allocated by different alloc_pages() calls. ext4_mpage_readpages() however does so: adjacent pages end up being passed together to dma_direct_map_sg(). To prevent this, jump directly to the buffer_head-based read function in KMSAN builds. Signed-off-by: Alexander Potapenko Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: linux-mm@kvack.org --- Change-Id: I54ae8af536626a988e6398ff18a06c179b0ce034 --- fs/ext4/readpage.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index a30b203fa461..a3bb9e3ce5de 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -252,6 +252,17 @@ int ext4_mpage_readpages(struct address_space *mapping, if (page_has_buffers(page)) goto confused; +#if defined(CONFIG_KMSAN) + /* + * The following code may treat adjacent pages allocated + * separately as a bigger contiguous allocation. + * KMSAN doesn't allow this, as the corresponding metadata + * pages may be separated. + * Skip this complex logic for KMSAN builds. + */ + goto confused; +#endif + block_in_file = (sector_t)page->index << (PAGE_SHIFT - blkbits); last_block = block_in_file + nr_pages * blocks_per_page; last_block_in_file = (ext4_readpage_limit(inode) +