Message ID | 20220329124017.737571-45-glider@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 D92BEC433EF for <linux-mm@archiver.kernel.org>; Tue, 29 Mar 2022 12:42:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EDC78D001E; Tue, 29 Mar 2022 08:42:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69FA28D0006; Tue, 29 Mar 2022 08:42:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53F4E8D001E; Tue, 29 Mar 2022 08:42:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 471528D0006 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 08:42:28 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 24833601E6 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:42:28 +0000 (UTC) X-FDA: 79297387176.11.6154163 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf31.hostedemail.com (Postfix) with ESMTP id AC7B120010 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:42:27 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id hz15-20020a1709072cef00b006dfeceff2d1so8118076ejc.17 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 05:42:27 -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=GRTJFN5fI/eCQ6Ah2RQjb7/dqw7JAuAGzue9isPThnU=; b=V2A969r8azagnZbvbCjDak0q6MRkqtC8n5tFydFSoeWA+AZwbef6NPKlrrU+H+BRBM P6taNp8QY9FavRqmNYSwqrdYGQ97zsjJxhBcCNj+utxQuJ9nOPiopPtbBqzQ8gBr6Qzm 7SYENQDGsHWHESxdBNNfqefvYaEkKbqQ7Uw9rn3v77vq15hOdIJrJeEt188vunugqZcn Y6At8xC/ehmqb5IdQtbwYrfxqEDNNN28/KTOPS67Mp49F5QHDODlthVjEKpkMZlKaPm0 nF0jHasnFvBSUC3gLePFYURhT77L4PhtEKIV+vHO9KG0REyFSTNFBTme4w/CaQQAv4EV cm0Q== 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=GRTJFN5fI/eCQ6Ah2RQjb7/dqw7JAuAGzue9isPThnU=; b=vXr8d+oGlWFtAGwL1oRFKA2JyNavSTxd3VKiEDfzvGuw7zTDErVmOIFMkGse7WcXB2 twdmty+z926w9My+7Uis+82omPkgKpCP0zftkNJYepbSMTGUbrSYpGJI9gn99SsUlXMq BMGJxkoy9MoZKj9vsolpapcJ1Il6Ao9u5u0+wr15y5Nh4nJu7CweMtZ7WPj7VpXq0b/N xU0h0K/E5Jta7TmSznOr8tPq7kDuoLWA4dVeDwZBaBQy3+EC543efHL36t/5nvs6LIyQ 3iPDv31eZ71hZJ4ruOkWGalf9eqhij/NAvYUiwjZ4lTTY6L2hhh7Ha6R0r0OWyNNCHg2 7Ysg== X-Gm-Message-State: AOAM5304q/Ryp0dGvn+0bb+RL54wp5udEPie16060R7GD1SBDxyFFJ4y xYFkrrxM/3zXiJxySlw76Up6yLTa+vQ= X-Google-Smtp-Source: ABdhPJzeBfVX40XVB+0DxQzCOfCbyY7YIWfJ+7MS3btbGbfEX8I9gsHnpMWWbEmqsPh4mt6QWJwzC2vkQok= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:907:c02:b0:6df:fb64:2770 with SMTP id ga2-20020a1709070c0200b006dffb642770mr34762165ejc.221.1648557746364; Tue, 29 Mar 2022 05:42:26 -0700 (PDT) Date: Tue, 29 Mar 2022 14:40:13 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-45-glider@google.com> Mime-Version: 1.0 References: <20220329124017.737571-1-glider@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog Subject: [PATCH v2 44/48] x86: kmsan: sync metadata pages on page fault From: Alexander Potapenko <glider@google.com> To: glider@google.com Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Andrew Morton <akpm@linux-foundation.org>, Andrey Konovalov <andreyknvl@google.com>, Andy Lutomirski <luto@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Borislav Petkov <bp@alien8.de>, Christoph Hellwig <hch@lst.de>, Christoph Lameter <cl@linux.com>, David Rientjes <rientjes@google.com>, Dmitry Vyukov <dvyukov@google.com>, Eric Dumazet <edumazet@google.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Herbert Xu <herbert@gondor.apana.org.au>, Ilya Leoshkevich <iii@linux.ibm.com>, Ingo Molnar <mingo@redhat.com>, Jens Axboe <axboe@kernel.dk>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Kees Cook <keescook@chromium.org>, Marco Elver <elver@google.com>, Mark Rutland <mark.rutland@arm.com>, Matthew Wilcox <willy@infradead.org>, "Michael S. Tsirkin" <mst@redhat.com>, Pekka Enberg <penberg@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Petr Mladek <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, Vasily Gorbik <gor@linux.ibm.com>, Vegard Nossum <vegard.nossum@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Stat-Signature: bubs8iakrq7c995uf71qat8oi5cyn9xk Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=V2A969r8; spf=pass (imf31.hostedemail.com: domain of 3sv5CYgYKCNM5A723G5DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3sv5CYgYKCNM5A723G5DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: AC7B120010 X-HE-Tag: 1648557747-630959 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: <linux-mm.kvack.org> |
Series |
Add KernelMemorySanitizer infrastructure
|
expand
|
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index d0074c6ed31a3..f2250a32a10ca 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -260,7 +260,7 @@ static noinline int vmalloc_fault(unsigned long address) } NOKPROBE_SYMBOL(vmalloc_fault); -void arch_sync_kernel_mappings(unsigned long start, unsigned long end) +static void __arch_sync_kernel_mappings(unsigned long start, unsigned long end) { unsigned long addr; @@ -284,6 +284,27 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end) } } +void arch_sync_kernel_mappings(unsigned long start, unsigned long end) +{ + __arch_sync_kernel_mappings(start, end); +#ifdef CONFIG_KMSAN + /* + * KMSAN maintains two additional metadata page mappings for the + * [VMALLOC_START, VMALLOC_END) range. These mappings start at + * KMSAN_VMALLOC_SHADOW_START and KMSAN_VMALLOC_ORIGIN_START and + * have to be synced together with the vmalloc memory mapping. + */ + if (start >= VMALLOC_START && end < VMALLOC_END) { + __arch_sync_kernel_mappings( + start - VMALLOC_START + KMSAN_VMALLOC_SHADOW_START, + end - VMALLOC_START + KMSAN_VMALLOC_SHADOW_START); + __arch_sync_kernel_mappings( + start - VMALLOC_START + KMSAN_VMALLOC_ORIGIN_START, + end - VMALLOC_START + KMSAN_VMALLOC_ORIGIN_START); + } +#endif +} + static bool low_pfn(unsigned long pfn) { return pfn < max_low_pfn;
KMSAN assumes shadow and origin pages for every allocated page are accessible. For pages between [VMALLOC_START, VMALLOC_END] those metadata pages start at KMSAN_VMALLOC_SHADOW_START and KMSAN_VMALLOC_ORIGIN_START, therefore we must sync a bigger memory region. Signed-off-by: Alexander Potapenko <glider@google.com> --- v2: -- addressed reports from kernel test robot <lkp@intel.com> Link: https://linux-review.googlesource.com/id/Ia5bd541e54f1ecc11b86666c3ec87c62ac0bdfb8 --- arch/x86/mm/fault.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)