Message ID | 20220915150417.722975-37-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 6B404ECAAA1 for <linux-mm@archiver.kernel.org>; Thu, 15 Sep 2022 15:06:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 034848D000B; Thu, 15 Sep 2022 11:06:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F25898D0001; Thu, 15 Sep 2022 11:06:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC6D68D000B; Thu, 15 Sep 2022 11:06:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C33E48D0001 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 11:06:18 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 93665140789 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 15:06:18 +0000 (UTC) X-FDA: 79914645636.08.B17E1AA Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf26.hostedemail.com (Postfix) with ESMTP id 2A3281400D0 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 15:06:17 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id l5-20020adfa385000000b0022a482f8285so4312641wrb.5 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 08:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=y4+04AEFcGK6lJisKBf+d7wj7/tgJIfosEPW0CJiM4s=; b=TY9zj9hsonLfxsKiJ/Nk2jseei3hK6yzpjZdnJr1tEyHclD4r1lmduXOFaXWThcHMB DJaob/V+m/PRO6csCY9Qz7+UxT/duZ0JLxrjFhCX78YuVaTTZumMHyb2TWgLeR3UbElB 7X4tMiqGIMatHsfHnsy6juWEIz1QNOu/tb14hyG2cs2B6k04dPWvwNIFfjy6W/oOeaN0 QrnIqe66ITykN//4B+h/MckE3RzTc0/Lsnyh0ahzj+igL5hjBzIYjNA8Ky1MP7CzfGn4 gexfdk9N6b5itmc9hr0TODSZeATm0DUea9IoCzI93/y47kt1AL6SpSZT+FyLO6lv3DEl 7UAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=y4+04AEFcGK6lJisKBf+d7wj7/tgJIfosEPW0CJiM4s=; b=77OJIkBwsyUyokAOp/iH6rknW56e1oG/F9U/bxdesDDV+Cs1moTE9PKpS2CtjJ2292 m58JQ1lhWXFhSyg/oO7kNQiTPUyy0Nn9cDWATQEavUxOv5QJ8/WjRHJbJ2cwgst3Ldgf hBtMRMeSEpAOm5BQ1/ZuURtHdEeVutgyYZcljIN8rZwMvdoPJrv34rNxmZP6MU/1o4hA 2bIe0Y5/QqvP+snwMgRHzLvtfub289wTPl3S+fbHSiK1EexdpMXM7bRUGyPhhGVTdlN6 UD2TIwQLpidVFVrF20nviLw21/OYDJFBT2x7cJBVtDHmw4ci0y/6S85ibWKnp+hruXOL xpKQ== X-Gm-Message-State: ACrzQf2Sqr0GMPSPI2XCjY2cyXWcJ8z2hMlp//Dr5vXm8YADLSw/SBMx kzK0vvFRD8NYGJRBKiEfJlTvXvpFlKA= X-Google-Smtp-Source: AMsMyM7TO7pwHZKC5FCuc6aosYGc8fP10GsQWeB+vHWTvsz1rJA3jVBR26bmI08PTxhgRL6r8YIYohpf0Dw= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:686d:27b5:495:85b7]) (user=glider job=sendgmr) by 2002:a05:6000:68c:b0:22a:bde3:f8cc with SMTP id bo12-20020a056000068c00b0022abde3f8ccmr71217wrb.556.1663254376855; Thu, 15 Sep 2022 08:06:16 -0700 (PDT) Date: Thu, 15 Sep 2022 17:04:10 +0200 In-Reply-To: <20220915150417.722975-1-glider@google.com> Mime-Version: 1.0 References: <20220915150417.722975-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220915150417.722975-37-glider@google.com> Subject: [PATCH v7 36/43] 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>, Alexei Starovoitov <ast@kernel.org>, 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 Biggers <ebiggers@kernel.org>, 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>, Stephen Rothwell <sfr@canb.auug.org.au>, 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>, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=TY9zj9hs; spf=pass (imf26.hostedemail.com: domain of 3aD8jYwYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com designates 209.85.221.74 as permitted sender) smtp.mailfrom=3aD8jYwYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663254378; a=rsa-sha256; cv=none; b=DoHdobWVI8Ucew2CJAL58rRFYhp1hiAbc/164BGW92ghT3oPrjjsLytdvxoeP0RPAVGetq 1OQWEvKKigq4N4QrVnZzHKhfXna/LX8gYPCA1rbysQE13RSZGlOKUWq7SOmN8rikEOjZVU KQ/qzgczSgzgMV0A4YdQNolb8DLqTrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663254378; 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=y4+04AEFcGK6lJisKBf+d7wj7/tgJIfosEPW0CJiM4s=; b=xU6Fw1EsCxdPNEaKRAZV5P387pVIazfvHw7pH2nCopeVqJQqIfeZNDYmP3DuD5NuH7lK6V mST2G72B4blx+ahERkJ8G1F+7C2mItlulWhMAFGNOgBWvqwyTtB063EtJmsyrZbOBqRVaA yXOdXruB/oaQM8IHTVAAi5Hx5PSNmK0= X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2A3281400D0 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=TY9zj9hs; spf=pass (imf26.hostedemail.com: domain of 3aD8jYwYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com designates 209.85.221.74 as permitted sender) smtp.mailfrom=3aD8jYwYKCJM38501E3BB381.zB985AHK-997Ixz7.BE3@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 99ssom5xkfb6zf55634fb3pogkhb4ifw X-HE-Tag: 1663254377-441601 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 fa71a5d12e872..d728791be8ace 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(-)