From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by gnuweeb.org (Postfix) with ESMTPS id 29E037EC2D for ; Thu, 16 Jun 2022 17:49:43 +0000 (UTC) Authentication-Results: gnuweeb.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pfDQHgzm; dkim-atps=neutral Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B29DBB824F8; Thu, 16 Jun 2022 17:49:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 497A1C34114; Thu, 16 Jun 2022 17:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655401779; bh=jp1i6DksrsdnGuY6hAh7dLb7WYttM9+yqrIKrAy/6uE=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=pfDQHgzmtWaBJKpDvwlmP1yzyxM5SWS61HqtJm3N3UJpsz67Tj9NYlEsuiXWCAUY9 nAv9iSGsY3Duygyt2kbPm/womtj8NXdaeaepILarnRrSfKIC6RFUnP3XuGG9ZbS7u+ gWG1eb1TJ9v9jXCLLnCPeIz/HR+6CFbjiunK5rFraJcFqORYiwTlpumQDnttPM05ds G3mX9xDcZA2UEoG80sC1FKyC9doKe/MkSNFi8T2V3wE8b3Q/KTeMDovBJoivL71LiD XQN3f+LdlQnniIp3wmAEKu1hmHS8ysa3Fg0+ASs5LTKSBYE3A4tHDS8aq+FckhI63Z yJm3Te9ouN4eg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AFB135C0531; Thu, 16 Jun 2022 10:49:38 -0700 (PDT) Date: Thu, 16 Jun 2022 10:49:38 -0700 From: "Paul E. McKenney" To: Marco Elver Cc: kernel test robot , Frederic Weisbecker , kbuild-all@lists.01.org, GNU/Weeb Mailing List , linux-kernel@vger.kernel.org, dvyukov@google.com Subject: Re: [ammarfaizi2-block:paulmck/linux-rcu/pmladek.2022.06.15a 133/140] vmlinux.o: warning: objtool: __ct_user_exit+0x41: call to __kasan_check_read() leaves .noinstr.text section Message-ID: <20220616174938.GR1790663@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <202206160411.v3iL3YC0-lkp@intel.com> <20220615204039.GI1790663@paulmck-ThinkPad-P17-Gen-1> <20220615211717.GA972937@paulmck-ThinkPad-P17-Gen-1> <20220616134021.GP1790663@paulmck-ThinkPad-P17-Gen-1> <20220616164416.GA2130702@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: On Thu, Jun 16, 2022 at 07:32:14PM +0200, Marco Elver wrote: > On Thu, 16 Jun 2022 at 18:44, Paul E. McKenney wrote: > [...] > > > > > > > >> vmlinux.o: warning: objtool: __ct_user_exit+0x41: call to __kasan_check_read() leaves .noinstr.text section > > > > > > > >> vmlinux.o: warning: objtool: __ct_user_enter+0x7f: call to __kasan_check_read() leaves .noinstr.text section > [...] > > > > It's due to the atomic_read()s within the noinstr function. Within > > > > noinstr you can use arch_atomic_read() to avoid the instrumentation. > > > > > > Thank you, will fix! > > > > And please see below for an alleged fix. > > Looks good, if this made the above warnings go away. Here is hoping! I will see if I can reproduce locally. ;-) > Btw, it's not just KASAN, but arch_atomic_read() also disables KCSAN > checking. A similar warning would have been generated in a KCSAN > config. Good to know, thank you! Additional local-reproduce opportunities. > Reviewed-by: Marco Elver Applied, thank you! Thanx, Paul > > ------------------------------------------------------------------------ > > > > commit 81e24ca26ee9933bcacf67a61e3f6ae41a025442 > > Author: Paul E. McKenney > > Date: Thu Jun 16 09:30:37 2022 -0700 > > > > context_tracking: Use arch_atomic_read() in __ct_state for KASAN > > > > Context tracking's __ct_state() function can be invoked from noinstr state > > where RCU is not watching. This means that its use of atomic_read() > > causes KASAN to invoke the non-noinstr __kasan_check_read() function > > from the noinstr function __ct_state(). This is problematic because > > someone tracing the __kasan_check_read() function could get a nasty > > surprise because of RCU not watching. > > > > This commit therefore replaces the __ct_state() function's use of > > atomic_read() with arch_atomic_read(), which KASAN does not attempt to > > add instrumention to. > > > > Signed-off-by: Paul E. McKenney > > Cc: Frederic Weisbecker > > Cc: Marco Elver > > > > diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h > > index 0aecc07fb4f50..81c51e5f03143 100644 > > --- a/include/linux/context_tracking_state.h > > +++ b/include/linux/context_tracking_state.h > > @@ -49,7 +49,7 @@ DECLARE_PER_CPU(struct context_tracking, context_tracking); > > > > static __always_inline int __ct_state(void) > > { > > - return atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK; > > + return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK; > > } > > #endif > >