Message ID | 20220905122452.2258262-38-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 8161AECAAD3 for <linux-mm@archiver.kernel.org>; Mon, 5 Sep 2022 12:26:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C2F68D008C; Mon, 5 Sep 2022 08:26:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 174598D0076; Mon, 5 Sep 2022 08:26:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03AC48D008C; Mon, 5 Sep 2022 08:26:40 -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 E94F98D0076 for <linux-mm@kvack.org>; Mon, 5 Sep 2022 08:26:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CC85B121405 for <linux-mm@kvack.org>; Mon, 5 Sep 2022 12:26:40 +0000 (UTC) X-FDA: 79877955360.14.B121128 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf25.hostedemail.com (Postfix) with ESMTP id 7B880A0079 for <linux-mm@kvack.org>; Mon, 5 Sep 2022 12:26:40 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id qa35-20020a17090786a300b0073d4026a97dso2257154ejc.9 for <linux-mm@kvack.org>; Mon, 05 Sep 2022 05:26:40 -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=gBW+tZSLxGZnND4jrchBsghKl8/54pySEDlyRdlr3psJ/Hvd7VXlx2wfj6ECdvmUQi sRTttLdDmy8zOhLjlaiCYzBsWtLdTMT8cmyabpe9q0MWsHkFkNMgKrt1Kn8/asTah7ZT H6TsR0U0wbSPvK4a+Dn7G+e/iNVEda36hWolwcehaapqlon8rlllNIzqQKO9iAA0Un/8 Nz12cRDUDSP+JcyVeGaQDbPYXAdFlP+cE5B3/TKbaZ+UJjg/9BZo0cHg67GtE9TCDPWu bFXqLAs8ynH14qtiFqkJTIrl8/aPUNXCg2mJ4yBGSqjV3wD2S0fjbX1I1vr87dz8Dh6a mFvg== 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=JDZjMwSW6henl65PBHZ4TXcZv9umFbzQljfa0vTj4p+CfRg3n++FxoFpX0KWb0bcSC T93hiLYBTTLO8USZS74DSGkJo8bIaKGotnyW5+uHCRenOMwFVNFivnc6ZFdV51OFOqP0 Unh6/JxU/EbuNXuXqKMdYQrxATggDzwnTnPfldnwZbZUh91XU7NvMV+mluRjLwBQz7ea dlf8LpCEoafHzdbVdjDjpRJHrKoc1uLkfX5EVafVGofLXt6Y/UYkFurEtXBXtaj4BcUb UVT74SKr9RYjrXQkCr7ZsfqhR52sN7vqMoH6j7cAeXZ563jD71C1WOm56dAAjvvwTvlh bZbA== X-Gm-Message-State: ACgBeo1m4Tq4eaZV3q0YcETZ2pptpOY3bgYTuASIUxyQIjiDKx29XsMv T7epolOWVY7tQ79iCCeK9sNdQ1j2cwE= X-Google-Smtp-Source: AA6agR7T0dnY+WLIWZ049DPiC2qaPW6QsYICvGVoSrCTFAnpUI8NVaVqBkaF1S6uhuuJRKOYM2t5hyE1pCs= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:b808:8d07:ab4a:554c]) (user=glider job=sendgmr) by 2002:a05:6402:10d2:b0:445:d9ee:fc19 with SMTP id p18-20020a05640210d200b00445d9eefc19mr41641834edu.81.1662380799213; Mon, 05 Sep 2022 05:26:39 -0700 (PDT) Date: Mon, 5 Sep 2022 14:24:45 +0200 In-Reply-To: <20220905122452.2258262-1-glider@google.com> Mime-Version: 1.0 References: <20220905122452.2258262-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220905122452.2258262-38-glider@google.com> Subject: [PATCH v6 37/44] 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 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>, 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662380800; 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=1Dl4WbiDrVD0pKFRnI+f10ZMACCbu2ASC8kHecQpErq6qKi0I+zv9sfLl9b/fxJ/JRSHe1 Rn80wg7ynZFWINvvtGb4/lIIor4W/Mof8eo6fqsAKzRo0nD53Rc/SB5UywJw0uBTty4qUH TZvcciZFnXwwweuriLYChq4tDDNGzBo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=gBW+tZSL; spf=pass (imf25.hostedemail.com: domain of 3_-oVYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3_-oVYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662380800; a=rsa-sha256; cv=none; b=zjoyKVJF7/974FHfShrvPGJLBmUQ2A8MZf8F8xmyXIMI7QJvkNgnRQMu0WcwjG6CnCKOda Cu6tf8/nuj1eNIVIkp/8ZrIVy4DqM8vG3DLuZGiCdMGQbnub6i6MsFuDOMxxQnfORrQhot tW0Zsic4FZH3SqEUBfiESXgUR99xpGY= X-Rspam-User: X-Stat-Signature: 1r5xs1t7ad6encz1mtgau68fkyu86c4z X-Rspamd-Queue-Id: 7B880A0079 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=gBW+tZSL; spf=pass (imf25.hostedemail.com: domain of 3_-oVYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3_-oVYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam04 X-HE-Tag: 1662380800-846367 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(-)