Message ID | 20220329124017.737571-40-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 503C8C433FE for <linux-mm@archiver.kernel.org>; Tue, 29 Mar 2022 12:42:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7DF28D0019; Tue, 29 Mar 2022 08:42:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D06F28D0018; Tue, 29 Mar 2022 08:42:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCE978D0019; Tue, 29 Mar 2022 08:42:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id AF5308D0018 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 08:42:15 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 60DCA1828A809 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:42:15 +0000 (UTC) X-FDA: 79297386630.20.B2A1FBE Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf26.hostedemail.com (Postfix) with ESMTP id E903B140014 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 12:42:14 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id x2-20020a1709065ac200b006d9b316257fso8150475ejs.12 for <linux-mm@kvack.org>; Tue, 29 Mar 2022 05:42:14 -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=vfNewWnsnLKjgrLxloInM3ksKktMuhZ88Cjjen8dSfw=; b=k2grIaWEX10+pjmxqhkcyCA78d3h23qdz2hQwriW/AtBkEbXWlTAWHSjR5jVjwbRd0 HKX1zG6uUcVNaozu8WxucSiCuQwHnnudt3nW2uxWtac7hF54EJ1kbSIlqPv4TwsjdCTr G92SqYktPjAwRps3tSeMbzJyGmoMawImGJXnVDm7RQbHHOMHmWqFKxMC2IeRQOg1Xhxq OJFN3e7mKc2NOaXlMGXsa9yHEVB8W3tfRWFhpSrRETeApxMNk01V3f1Rz7tcgby1LDeH XGjGGEIIihzXVuI4E4ZD/omsJ5xBfcLQ6Erf+tZ7ZaeE1xczews93WWLLOk7DrdHF6hz Ns5g== 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=vfNewWnsnLKjgrLxloInM3ksKktMuhZ88Cjjen8dSfw=; b=jSrGVmhALXgOngWnqtLaE8IREpMq0UgdieVVb2aYxZQ1bnqEyd2qsDeiyXEhEblsb1 QneHXKExXnOACA09vbfFGDnpFBsEDXyXPP04v0J1BvCXA+aIkslUZU0suYHMZRlfJoM2 aE7ydXZDJH8a0OUoKWkhbCk6X4mpEjHGQTkSEqn9H2pkuzixfKgGQBImcbgH2uI4JAZS 7UiFY9IXabpcJYSkkUHCYv8K/DdfAiol0Vvl/mYaDesJa+MgdqaD3n8DPOYaVC3cqiUb /DkYhVyDJH99ALfITmgxm8XQsvsiuL9kZIAcXL8b+ERPYG2gZbrCvBh5sfDxCKgnq8Cr aGDw== X-Gm-Message-State: AOAM5319AB32poHMtpUi59jqFSeGG4EGzLp7Xg5VHoj2+w8aYTwBzdL7 EcnVrxuHzl+GpyUFemCGeQs/mypjKDc= X-Google-Smtp-Source: ABdhPJxYhi4C5lMRGBP4ot4j5u4X+r6OfqpTJ+iIL9kMkH3POTY1BlEuc6eV3fFfpCDp3jcSR0ZuHMnxazU= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:906:2699:b0:6d0:9f3b:a6a7 with SMTP id t25-20020a170906269900b006d09f3ba6a7mr33007227ejc.397.1648557733360; Tue, 29 Mar 2022 05:42:13 -0700 (PDT) Date: Tue, 29 Mar 2022 14:40:08 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-40-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 39/48] x86: kmsan: make READ_ONCE_TASK_STACK() return initialized values 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" Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=k2grIaWE; spf=pass (imf26.hostedemail.com: domain of 3pf5CYgYKCMYsxupq3s00sxq.o0yxuz69-yyw7mow.03s@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3pf5CYgYKCMYsxupq3s00sxq.o0yxuz69-yyw7mow.03s@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 65xkbud7zefoczjttar6kcyqaytf5f1g X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E903B140014 X-HE-Tag: 1648557734-793591 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/include/asm/unwind.h b/arch/x86/include/asm/unwind.h index 2a1f8734416dc..51173b19ac4d5 100644 --- a/arch/x86/include/asm/unwind.h +++ b/arch/x86/include/asm/unwind.h @@ -129,18 +129,19 @@ unsigned long unwind_recover_ret_addr(struct unwind_state *state, } /* - * This disables KASAN checking when reading a value from another task's stack, - * since the other task could be running on another CPU and could have poisoned - * the stack in the meantime. + * This disables KASAN/KMSAN checking when reading a value from another task's + * stack, since the other task could be running on another CPU and could have + * poisoned the stack in the meantime. Frame pointers are uninitialized by + * default, so for KMSAN we mark the return value initialized unconditionally. */ -#define READ_ONCE_TASK_STACK(task, x) \ -({ \ - unsigned long val; \ - if (task == current) \ - val = READ_ONCE(x); \ - else \ - val = READ_ONCE_NOCHECK(x); \ - val; \ +#define READ_ONCE_TASK_STACK(task, x) \ +({ \ + unsigned long val; \ + if (task == current && !IS_ENABLED(CONFIG_KMSAN)) \ + val = READ_ONCE(x); \ + else \ + val = READ_ONCE_NOCHECK(x); \ + val; \ }) static inline bool task_on_another_cpu(struct task_struct *task)
To avoid false positives, assume that reading from the task stack always produces initialized values. Signed-off-by: Alexander Potapenko <glider@google.com> --- Link: https://linux-review.googlesource.com/id/I9e2350bf3e88688dd83537e12a23456480141997 --- arch/x86/include/asm/unwind.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)