Message ID | 20220701142310.2188015-33-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 8947BC43334 for <linux-mm@archiver.kernel.org>; Fri, 1 Jul 2022 14:24:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C5E86B0087; Fri, 1 Jul 2022 10:24:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2278B6B0088; Fri, 1 Jul 2022 10:24:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07C976B0089; Fri, 1 Jul 2022 10:24:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EC79E6B0087 for <linux-mm@kvack.org>; Fri, 1 Jul 2022 10:24:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CE960615CF for <linux-mm@kvack.org>; Fri, 1 Jul 2022 14:24:46 +0000 (UTC) X-FDA: 79638752172.14.F9C1B7B Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) by imf17.hostedemail.com (Postfix) with ESMTP id 72B7B4003F for <linux-mm@kvack.org>; Fri, 1 Jul 2022 14:24:46 +0000 (UTC) Received: by mail-ed1-f73.google.com with SMTP id y5-20020a056402358500b0043592ac3961so1867498edc.6 for <linux-mm@kvack.org>; Fri, 01 Jul 2022 07:24:46 -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=z3bEqNJSKGgtE+5cRSN2oSZAKY283RHsG2GOYMoI00Y=; b=qnQCWjKq5yG4F3jPwXLMHLCDtYd3ls2GTNlYs9o6Wm5n9ZlXM2kcHIEFbE0tYS3KKn HmTASR9qhhcfDdychxG1CfugY/2EWvcCDInodoMg7RU0zMb9HYdN78o9NjljMlNc8rMd hIPR0zujO1oAwrMaZfThO3gQ6658HJ1jfgOwDhl9ZusUhjpUAC4OrXaLRqEtr0Uzsch/ DsH42O9o1nqIfH3L8cjBMMq0dkqxJiiaM9JZTR6pQdrxlRJnL8p1AzkkSc/He2avvllk IPUugX4/4fHGoOL5a8zYmVOjP0tM9Ig0OyWFD1/fv11wQ/OCoEsmw4o/l++EGmFeYma8 W7cw== 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=z3bEqNJSKGgtE+5cRSN2oSZAKY283RHsG2GOYMoI00Y=; b=6Eomon3Tj0WT7tHS4aXKwu+brD/I4k/cwX2z+qSPVT57gq9iXzDfg/uKnMPtN73og1 XpMkcOFO6n2PIl07bp3UOtMPryHkjEfnJMqpSjjgJI7qHbpOGs5UskiHEvS9eI0s+umK mAi9SVeQVJh3ASeGZcAOA4B7ohCZNxfjU7vt8GkfDrItPBd0ifsKXZB/GMO/BahCZ05r b96z2DcfzW+jr3MHvkY0qEMehkIjWdYlRbs4cadcTvceEzELeWujXtbz+0AQW6zE/JqT elM+omWbGKLz7kUVmn+H8Ntgd8ByjX1n8rlndLt2bW938kKWWCUgpMg5ax6Fhm/ePRY3 LplQ== X-Gm-Message-State: AJIora+tkXyZcP3VsJXh8QuQXxFxNgS0Op0sZJ5XIhauriLj4cQqsE4P u5Q1d8skGLZyfQr9kthauLPddzMDQGo= X-Google-Smtp-Source: AGRyM1v3S88h3I8S3PNOLZJhMmyQhBUBhKM4ToewpYwCFFWW8Gw6EHSPC9ywT4YZ1DjScWDrCrHuxSVSgLc= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:a6f5:f713:759c:abb6]) (user=glider job=sendgmr) by 2002:a17:906:2086:b0:717:4e91:f1db with SMTP id 6-20020a170906208600b007174e91f1dbmr14229924ejq.345.1656685485180; Fri, 01 Jul 2022 07:24:45 -0700 (PDT) Date: Fri, 1 Jul 2022 16:22:57 +0200 In-Reply-To: <20220701142310.2188015-1-glider@google.com> Message-Id: <20220701142310.2188015-33-glider@google.com> Mime-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v4 32/45] objtool: kmsan: list KMSAN API functions as uaccess-safe 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-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qnQCWjKq; spf=pass (imf17.hostedemail.com: domain of 3rQO_YgYKCMwy30vw9y66y3w.u64305CF-442Dsu2.69y@flex--glider.bounces.google.com designates 209.85.208.73 as permitted sender) smtp.mailfrom=3rQO_YgYKCMwy30vw9y66y3w.u64305CF-442Dsu2.69y@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=1656685486; 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=z3bEqNJSKGgtE+5cRSN2oSZAKY283RHsG2GOYMoI00Y=; b=AYZhD8n7hbj+vRbacPVTYubiZYYESsbE/1K/ztqQpQJbCIWTyUeY9ksDG3Xs0PrlcyXouA sjEiu4KEDtgb1OdXHB6i2E9qZ4ISW7L+Q7IncRuk06g/4Xy1VEgvQWz2OIvuX3Dk4wpoTN v8jKcXa+cV8j8XOyYOtSAcFJcfzhnzw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656685486; a=rsa-sha256; cv=none; b=UYeYTwnZKx+1rrCChK7DZEarIGtI/FNHu0VbM3Ucauhh8Cq8Wul+JtSTxpGYyzJNgfdlYl kUbAa+0/3rmJVHNvUo5zEBvxVqOGd1SoVA+qsDQuGgRTA8QmGajz5sWeUwA3h+Bi7HGgkv jqeNm0UkbNP6Fh5cOOercDHXZqj2w2k= X-Stat-Signature: dkjadbhetmi9ufmigxk8gq98ybrhxx3y X-Rspamd-Queue-Id: 72B7B4003F Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qnQCWjKq; spf=pass (imf17.hostedemail.com: domain of 3rQO_YgYKCMwy30vw9y66y3w.u64305CF-442Dsu2.69y@flex--glider.bounces.google.com designates 209.85.208.73 as permitted sender) smtp.mailfrom=3rQO_YgYKCMwy30vw9y66y3w.u64305CF-442Dsu2.69y@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1656685486-12814 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/tools/objtool/check.c b/tools/objtool/check.c index 864bb9dd35845..1cf260c966441 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1013,6 +1013,26 @@ static const char *uaccess_safe_builtin[] = { "__sanitizer_cov_trace_cmp4", "__sanitizer_cov_trace_cmp8", "__sanitizer_cov_trace_switch", + /* KMSAN */ + "kmsan_copy_to_user", + "kmsan_report", + "kmsan_unpoison_entry_regs", + "kmsan_unpoison_memory", + "__msan_chain_origin", + "__msan_get_context_state", + "__msan_instrument_asm_store", + "__msan_metadata_ptr_for_load_1", + "__msan_metadata_ptr_for_load_2", + "__msan_metadata_ptr_for_load_4", + "__msan_metadata_ptr_for_load_8", + "__msan_metadata_ptr_for_load_n", + "__msan_metadata_ptr_for_store_1", + "__msan_metadata_ptr_for_store_2", + "__msan_metadata_ptr_for_store_4", + "__msan_metadata_ptr_for_store_8", + "__msan_metadata_ptr_for_store_n", + "__msan_poison_alloca", + "__msan_warning", /* UBSAN */ "ubsan_type_mismatch_common", "__ubsan_handle_type_mismatch",
KMSAN inserts API function calls in a lot of places (function entries and exits, local variables, memory accesses), so they may get called from the uaccess regions as well. KMSAN API functions are used to update the metadata (shadow/origin pages) for kernel memory accesses. The metadata pages for kernel pointers are also located in the kernel memory, so touching them is not a problem. For userspace pointers, no metadata is allocated. If an API function is supposed to read or modify the metadata, it does so for kernel pointers and ignores userspace pointers. If an API function is supposed to return a pair of metadata pointers for the instrumentation to use (like all __msan_metadata_ptr_for_TYPE_SIZE() functions do), it returns the allocated metadata for kernel pointers and special dummy buffers residing in the kernel memory for userspace pointers. As a result, none of KMSAN API functions perform userspace accesses, but since they might be called from UACCESS regions they use user_access_save/restore(). Signed-off-by: Alexander Potapenko <glider@google.com> --- v3: -- updated the patch description v4: -- add kmsan_unpoison_entry_regs() Link: https://linux-review.googlesource.com/id/I242bc9816273fecad4ea3d977393784396bb3c35 --- tools/objtool/check.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)