Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1327549pxb; Wed, 30 Mar 2022 00:22:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7hR0nIcqr4k/LYdlv+Okpmo5QnEW2X5wERZJInEqFljLqxHwkhJw3ZhEINsZbkVgaw4Jq X-Received: by 2002:a17:907:6e93:b0:6df:8c1a:d08b with SMTP id sh19-20020a1709076e9300b006df8c1ad08bmr38282048ejc.557.1648624947039; Wed, 30 Mar 2022 00:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648624947; cv=none; d=google.com; s=arc-20160816; b=yQ1dbJAjQjXsj8i5w3CfsDCzMyQtAoydBQ8ddruEyLUslC2Cqed/OghEEm9g9kZp4Y dEd8WEAiKM4h0eODwTeMMt+oEzuZHslC9FTsucTGLWtXlcu41egE/InUGNhRrqRtGUCx wPGDI+UTYf8lpLnnQb1igXFoYWjRSwfVEEqaESu6CjxcO0155xdfjrhTZe3OCK3H7+d9 d1AuDrn3/G2N5o6EaVuuuSdEiLjMiNBPJ+29epc173vpRfJNkqKFS9/sFvqBtbCFPWdR C/4YpxYmpM9FmHEiBgwzUuQMe/my4yeeocJmChWdfYmzg+v5H6zUrNYtOHq/Pd+h1raB AqQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=O02VuhTFNs3OTl+6EdHhE8hyAxR47CEkJ1c0ak5Vr4s=; b=D6rRNk8lMtTtO5ZIyV2K+pSJnTnA+Duhs51r7oWfZli7a95WOYZjWn7MMKPGMdMgjM 7CWGjuS3hepKFbTOOmFQ5O6rXG1GGFzs9YUaVldxneZvIhwtcfIk131aHCiR25mx40i1 Ft3KSJDwc8eSUo0LYGYS+JQGqO5rEZVo/Ck1jt7SkQTSU0wTzvsMhirk6peywrAtCdzP 4/54cIcFiQ9z5yBKJ1tdvTBtWfJ2oX4coKzyHoXRKgolEe6+13ybZd3nPbiEwMbflu9f pH9E6Pd8r/QcGUgW4uVG3pq/qYySREaa4dpLE+j4n+7ugAfTL7YOT9mGmIisYrbKilJu wPLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=C7gGD19m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a50cdcc000000b00418c2b5bf71si20933860edj.595.2022.03.30.00.22.00; Wed, 30 Mar 2022 00:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=C7gGD19m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236671AbiC2Mqj (ORCPT + 99 others); Tue, 29 Mar 2022 08:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236674AbiC2Moh (ORCPT ); Tue, 29 Mar 2022 08:44:37 -0400 Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5028238D2B for ; Tue, 29 Mar 2022 05:41:48 -0700 (PDT) Received: by mail-ej1-x64a.google.com with SMTP id my15-20020a1709065a4f00b006dfd2b16e6cso8136010ejc.1 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=rZVfnC+VxffSGzgk0JPbYpiyMyed5FmD2TIIUpINQWkkT5NCGrHqxhUKYPKTimkm/E y79THzfGbW3WobUD1qa03QnszKsKgdb/oziLfzp0JLDCEAHWPDVZY6az/78sc5d2DkYS WcJX4qvGyFPp0oPLwqAlERLtaFjYV/nAtLgOZe+fjdyY4BL6wsOP9JU/GMeDzEgUWiwj mN3n9QkJj2mLmgwMZZo8Flz8HkuvwirW/gJ2gX/BOkulgBmsTdJv5hYNK3NOFkGUgZrL K9okZeVCo8V4uRb4ZMXGc2gWsLpTMEYxA0p+eCBSiKgIyGBmGd6rPOz2GWS/Ew7tFFqD weEw== X-Gm-Message-State: AOAM530Yws6D2/rZmurJjS6zxb2TrDxBMYza/YhblOj1RgTjnir34L1D 9jByflcfbPPnPC0DinJH45MU8akoIyY= 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-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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