From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C247CC433F5 for ; Tue, 29 Mar 2022 12:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 569DA8D0003; Tue, 29 Mar 2022 08:41:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F1268D0001; Tue, 29 Mar 2022 08:41:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36ADB8D0003; Tue, 29 Mar 2022 08:41:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 28D6D8D0001 for ; Tue, 29 Mar 2022 08:41:49 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E0554A00FB for ; Tue, 29 Mar 2022 12:41:48 +0000 (UTC) X-FDA: 79297385496.28.451E7A1 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf15.hostedemail.com (Postfix) with ESMTP id 7A862A0007 for ; Tue, 29 Mar 2022 12:41:48 +0000 (UTC) Received: by mail-ed1-f74.google.com with SMTP id b71-20020a509f4d000000b00418d658e9d1so10843874edf.19 for ; Tue, 29 Mar 2022 05:41:48 -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=O02VuhTFNs3OTl+6EdHhE8hyAxR47CEkJ1c0ak5Vr4s=; b=C7gGD19m/XveB8Ws/Mrjzquo4UNw5iFhMF9IPlHcdW4Pk7ozQxZ0PNkEpCOMh/tb00 yCiWkUdHR91r9//CRvGweQPLnnFSzPbvrVzmonGkPHKHJKpSLL7cZLAlDCFYeFIGL0Ss /IHCNCWokewlL1qO8a1mb2PQPEKWlCRk5OzGhzGAqj2hGFDN9YdHtSVskka/fzfTrsMa j1HMSwQQR8sw9adaQ+zA9d1GRw1pKIsT10NfugO2m9bXeTnFmGN1T9OiXau82BOJCc7K C/JGIJ/LSEbzSTmqkiIN+J1LwkC97hJDp0NnsDzTO1d3X/gZnjcZCBRAdS59i777oAr4 GMUA== 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=O02VuhTFNs3OTl+6EdHhE8hyAxR47CEkJ1c0ak5Vr4s=; b=MVWXKQmYihoFmpkXYk+7pCAaUa2zYeJQMcW0MvIqoJhgSJbH9Fcw6A4sLEqz7pR8Bo XG0yHUG9eBDl/BM8p6oZgqztiRsmaiNyzoTV3Np7aO+d+Ok40gVplp5JXQ0M4YCaOWio FJPcAlDcikjzKweZVCGoW7D5P5AU1zOpiShnq2DOgXbCfXvPVL1/0X3bAJ7DE2nc+W5k rkx3tA/yYLJ6Q/9hp4U1lb1MPfrN0nv6LkbS2Rx2UOuE+oDqeH+BzNlKxoesIwkoTny0 x90qXWPEO7V2dUG03tbV0jhKnGvl3OX1GZznZVQpWDEqRuGgXz+qPF59QfKoJtl0MBPh z/vA== X-Gm-Message-State: AOAM533Px2PvuvjDzuhbFs0cJuJMIc5OS6cFNCaVceiXQJMdwU8SUrzu LBJYw1hIjRNdcfwUswJczh+6BcmVzSg= X-Google-Smtp-Source: ABdhPJyB/bcFcN+qpi65yKy1mIxhG89Sd6SxBmOpeaEdxDCuTuOOvV2uj+2kKbIDqHQp3uDGpI9M/qBVr2s= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:36eb:759:798f:98c3]) (user=glider job=sendgmr) by 2002:a17:906:4786:b0:6e0:c7b:d267 with SMTP id cw6-20020a170906478600b006e00c7bd267mr34808708ejc.115.1648557707096; Tue, 29 Mar 2022 05:41:47 -0700 (PDT) Date: Tue, 29 Mar 2022 14:39:58 +0200 In-Reply-To: <20220329124017.737571-1-glider@google.com> Message-Id: <20220329124017.737571-30-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 29/48] kmsan: entry: handle register passing from uninstrumented code From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7A862A0007 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=C7gGD19m; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of 3i_5CYgYKCKwSXUPQdSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3i_5CYgYKCKwSXUPQdSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--glider.bounces.google.com X-Stat-Signature: xkmobin3hqmazu91iogyy5mb316wwcjs X-HE-Tag: 1648557708-738340 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: Replace instrumentation_begin() with instrumentation_begin_with_regs() to let KMSAN handle the non-instrumented code and unpoison pt_regs passed from the instrumented part. Signed-off-by: Alexander Potapenko --- Link: https://linux-review.googlesource.com/id/I7f0a9809b66bd85faae43142971d0095771b7a42 --- kernel/entry/common.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/entry/common.c b/kernel/entry/common.c index bad713684c2e3..dcf91ab14512a 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -21,7 +21,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs) CT_WARN_ON(ct_state() != CONTEXT_USER); user_exit_irqoff(); - instrumentation_begin(); + instrumentation_begin_with_regs(regs); trace_hardirqs_off_finish(); instrumentation_end(); } @@ -103,7 +103,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) __enter_from_user_mode(regs); - instrumentation_begin(); + instrumentation_begin_with_regs(regs); local_irq_enable(); ret = __syscall_enter_from_user_work(regs, syscall); instrumentation_end(); @@ -114,7 +114,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs) { __enter_from_user_mode(regs); - instrumentation_begin(); + instrumentation_begin_with_regs(regs); local_irq_enable(); instrumentation_end(); } @@ -296,7 +296,7 @@ void syscall_exit_to_user_mode_work(struct pt_regs *regs) __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs) { - instrumentation_begin(); + instrumentation_begin_with_regs(regs); __syscall_exit_to_user_mode_work(regs); instrumentation_end(); __exit_to_user_mode(); @@ -309,7 +309,7 @@ noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs) noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs) { - instrumentation_begin(); + instrumentation_begin_with_regs(regs); exit_to_user_mode_prepare(regs); instrumentation_end(); __exit_to_user_mode(); @@ -357,7 +357,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs) */ lockdep_hardirqs_off(CALLER_ADDR0); rcu_irq_enter(); - instrumentation_begin(); + instrumentation_begin_with_regs(regs); trace_hardirqs_off_finish(); instrumentation_end(); @@ -372,7 +372,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs) * in having another one here. */ lockdep_hardirqs_off(CALLER_ADDR0); - instrumentation_begin(); + instrumentation_begin_with_regs(regs); rcu_irq_enter_check_tick(); trace_hardirqs_off_finish(); instrumentation_end(); @@ -409,7 +409,7 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) * and RCU as the return to user mode path. */ if (state.exit_rcu) { - instrumentation_begin(); + instrumentation_begin_with_regs(regs); /* Tell the tracer that IRET will enable interrupts */ trace_hardirqs_on_prepare(); lockdep_hardirqs_on_prepare(CALLER_ADDR0); @@ -419,7 +419,7 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) return; } - instrumentation_begin(); + instrumentation_begin_with_regs(regs); if (IS_ENABLED(CONFIG_PREEMPTION)) { #ifdef CONFIG_PREEMPT_DYNAMIC static_call(irqentry_exit_cond_resched)(); @@ -451,7 +451,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs) lockdep_hardirq_enter(); rcu_nmi_enter(); - instrumentation_begin(); + instrumentation_begin_with_regs(regs); trace_hardirqs_off_finish(); ftrace_nmi_enter(); instrumentation_end(); @@ -461,7 +461,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs) void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state) { - instrumentation_begin(); + instrumentation_begin_with_regs(regs); ftrace_nmi_exit(); if (irq_state.lockdep) { trace_hardirqs_on_prepare(); -- 2.35.1.1021.g381101b075-goog