Message ID | 20220826150807.723137-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 772D3ECAAA3 for <linux-mm@archiver.kernel.org>; Fri, 26 Aug 2022 15:09:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 130EF940012; Fri, 26 Aug 2022 11:09:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BA23940007; Fri, 26 Aug 2022 11:09:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7634940012; Fri, 26 Aug 2022 11:09:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D5384940007 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 11:09:58 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B2DD3160E62 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 15:09:58 +0000 (UTC) X-FDA: 79842078876.31.D9E065F Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf18.hostedemail.com (Postfix) with ESMTP id 57B261C0024 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 15:09:58 +0000 (UTC) Received: by mail-ed1-f74.google.com with SMTP id z6-20020a05640240c600b0043e1d52fd98so1242184edb.22 for <linux-mm@kvack.org>; Fri, 26 Aug 2022 08:09:58 -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; bh=03rMp3Lo5JUXz6YDRuTXWFQl7G4ZPrO7G1beymmSRqE=; b=sAVtSR5T+WmzYcO0y/rL5vqCNNkvHaCr2ijspx7pp0tTQssYQZLgmJ9706bnECI/Pi YvE0hXaOB/bpoPUuj28jQP33PpftgYXVTG+qpwIi3L5mxwe+6kaftp5iFooMAa5EApv+ 4Xho0ql82BCrzE6U0OTZGJ/taBfHGO1y8osby63H8xs97a7h4A461xjeIy2Zy7keH0xZ +t+I84JRMBYSgKA0pc92tEXu95OISOZBUXZ056nBZFYe+Q+0daqg0RU0hYyWf00i7zRH 6jRE7es/OUAGkP/ew2ox8ehfjiFp5faSOGaeaVZskTV8TnVAMbg5VUMNyZ3ZbwBFqN1c qKMg== 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; bh=03rMp3Lo5JUXz6YDRuTXWFQl7G4ZPrO7G1beymmSRqE=; b=mp6bNcEUj42Gky8uGMX4mxHh5RMUWLWDnG785uUzsXUqIhx2d3WYQ1QY7AFmITzYTf ZS6uKCPS/xLY/GpPVXmpaKh3KJ14ktrfky0jppQcH/rJ2wu2ug+M7YI1XKisRnVTktyM gmBk7uzuCYc+RE1E19EvXbVnX8pZh9+6IOImMV2zUs5tB1EM68fhj+zaMdWhtlkgfTxr 943KxS9fbVT1bIpyKpJKajEQIJ6+4ErEC46AansoAo1l4c1TSQo7zuceoeP4lW1b9Uk8 WVrJsJtyoxdIXp7em6DcU3g7AyaptyYA7DI3kg9sPshXSraj1oscwe5ouA7oNFNj7V1D QN4Q== X-Gm-Message-State: ACgBeo3FAT5/+8nrJO+s6XusG2wF1poiVDtlJMngUDu9FdiTzgW73rg6 FudboCi3m0hZ/29iaLURidP5kkY+lk8= X-Google-Smtp-Source: AA6agR5sfXXazfCHPhI3z6MZ77T83FgZy9TTJ1m+QzHsaIqLLsWY/SYhrcqQDvh5VnxcE117PZ//mWwCuBo= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:5207:ac36:fdd3:502d]) (user=glider job=sendgmr) by 2002:a05:6402:26c6:b0:446:b4aa:5d00 with SMTP id x6-20020a05640226c600b00446b4aa5d00mr7346330edd.63.1661526597110; Fri, 26 Aug 2022 08:09:57 -0700 (PDT) Date: Fri, 26 Aug 2022 17:08:00 +0200 In-Reply-To: <20220826150807.723137-1-glider@google.com> Mime-Version: 1.0 References: <20220826150807.723137-1-glider@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220826150807.723137-38-glider@google.com> Subject: [PATCH v5 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661526598; a=rsa-sha256; cv=none; b=bLhvUtpPYhvqog8DL8mlJnaLVrMmEC7nZkwehzOvT5dZkmyfRuOVeEzg+qf1EgQgT4206M gudF9UyTL1RXzNGhyS9Izu9EjHqYCOlSGiKAk4p9MFpcEe8e5DhntYGNnm55UbVRhX3QOk TrObMQbeXq56JCOI6TWP/Yb+Va0/7jQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sAVtSR5T; spf=pass (imf18.hostedemail.com: domain of 3ReIIYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3ReIIYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661526598; 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=03rMp3Lo5JUXz6YDRuTXWFQl7G4ZPrO7G1beymmSRqE=; b=O1R9ASKZizvSrksMMe+pdKo5hfNAxON8OTvkaKstYOQsOYoLVSzOdE1w7NDvAQ8T9IHA6K xGYFa0cvICb6h9ZOMG2kIFZyI7BkNyXy6iLs4aaAVbr1CLlEhUS69P+3FXm11x6iEhCBBu EelWohnS9dKdreGDRtQjliqds5Yatdg= X-Stat-Signature: b6pnyfqj4m6rk1qhxr8a5q8fjyfytndu X-Rspamd-Queue-Id: 57B261C0024 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sAVtSR5T; spf=pass (imf18.hostedemail.com: domain of 3ReIIYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3ReIIYwYKCEwuzwrs5u22uzs.q20zw18B-00y9oqy.25u@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1661526598-804393 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(-)