public inbox for [email protected]
 help / color / mirror / Atom feed
* [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
@ 2022-06-15 20:26 kernel test robot
  2022-06-15 20:40 ` Paul E. McKenney
  0 siblings, 1 reply; 8+ messages in thread
From: kernel test robot @ 2022-06-15 20:26 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: kbuild-all, GNU/Weeb Mailing List, linux-kernel, Paul E. McKenney

tree:   https://github.com/ammarfaizi2/linux-block paulmck/linux-rcu/pmladek.2022.06.15a
head:   0ba7324b44282870af740a5a121add62c7f5f730
commit: db21b02f8044e812f8a5e3811f602409290e3ede [133/140] context_tracking: Convert state to atomic_t
config: x86_64-randconfig-r003-20220516 (https://download.01.org/0day-ci/archive/20220616/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/ammarfaizi2/linux-block/commit/db21b02f8044e812f8a5e3811f602409290e3ede
        git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
        git fetch --no-tags ammarfaizi2-block paulmck/linux-rcu/pmladek.2022.06.15a
        git checkout db21b02f8044e812f8a5e3811f602409290e3ede
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> 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

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* 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
  2022-06-15 20:26 [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 kernel test robot
@ 2022-06-15 20:40 ` Paul E. McKenney
  2022-06-15 21:17   ` Paul E. McKenney
  0 siblings, 1 reply; 8+ messages in thread
From: Paul E. McKenney @ 2022-06-15 20:40 UTC (permalink / raw)
  To: kernel test robot
  Cc: Frederic Weisbecker, kbuild-all, GNU/Weeb Mailing List,
	linux-kernel

On Thu, Jun 16, 2022 at 04:26:16AM +0800, kernel test robot wrote:
> tree:   https://github.com/ammarfaizi2/linux-block paulmck/linux-rcu/pmladek.2022.06.15a
> head:   0ba7324b44282870af740a5a121add62c7f5f730
> commit: db21b02f8044e812f8a5e3811f602409290e3ede [133/140] context_tracking: Convert state to atomic_t
> config: x86_64-randconfig-r003-20220516 (https://download.01.org/0day-ci/archive/20220616/[email protected]/config)
> compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
> reproduce (this is a W=1 build):
>         # https://github.com/ammarfaizi2/linux-block/commit/db21b02f8044e812f8a5e3811f602409290e3ede
>         git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
>         git fetch --no-tags ammarfaizi2-block paulmck/linux-rcu/pmladek.2022.06.15a
>         git checkout db21b02f8044e812f8a5e3811f602409290e3ede
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <[email protected]>
> 
> All warnings (new ones prefixed by >>):
> 
> >> 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

Marco, Dmitry, my guess is that this is due to the ct->active check in
both functions.  Are we supposed to do something to make this sort of
thing safe for KASAN?

							Thanx, Paul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* 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
  2022-06-15 20:40 ` Paul E. McKenney
@ 2022-06-15 21:17   ` Paul E. McKenney
  2022-06-16  8:19     ` Marco Elver
  0 siblings, 1 reply; 8+ messages in thread
From: Paul E. McKenney @ 2022-06-15 21:17 UTC (permalink / raw)
  To: kernel test robot
  Cc: Frederic Weisbecker, kbuild-all, GNU/Weeb Mailing List,
	linux-kernel, elver, dvyukov

On Wed, Jun 15, 2022 at 01:40:39PM -0700, Paul E. McKenney wrote:
> On Thu, Jun 16, 2022 at 04:26:16AM +0800, kernel test robot wrote:
> > tree:   https://github.com/ammarfaizi2/linux-block paulmck/linux-rcu/pmladek.2022.06.15a
> > head:   0ba7324b44282870af740a5a121add62c7f5f730
> > commit: db21b02f8044e812f8a5e3811f602409290e3ede [133/140] context_tracking: Convert state to atomic_t
> > config: x86_64-randconfig-r003-20220516 (https://download.01.org/0day-ci/archive/20220616/[email protected]/config)
> > compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
> > reproduce (this is a W=1 build):
> >         # https://github.com/ammarfaizi2/linux-block/commit/db21b02f8044e812f8a5e3811f602409290e3ede
> >         git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
> >         git fetch --no-tags ammarfaizi2-block paulmck/linux-rcu/pmladek.2022.06.15a
> >         git checkout db21b02f8044e812f8a5e3811f602409290e3ede
> >         # save the config file
> >         mkdir build_dir && cp config build_dir/.config
> >         make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> > 
> > If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <[email protected]>
> > 
> > All warnings (new ones prefixed by >>):
> > 
> > >> 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
> 
> Marco, Dmitry, my guess is that this is due to the ct->active check in
> both functions.  Are we supposed to do something to make this sort of
> thing safe for KASAN?

This time actually CCing Marco and Dmitry...

							Thanx, Paul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* 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
  2022-06-15 21:17   ` Paul E. McKenney
@ 2022-06-16  8:19     ` Marco Elver
  2022-06-16 13:40       ` Paul E. McKenney
  0 siblings, 1 reply; 8+ messages in thread
From: Marco Elver @ 2022-06-16  8:19 UTC (permalink / raw)
  To: paulmck
  Cc: kernel test robot, Frederic Weisbecker, kbuild-all,
	GNU/Weeb Mailing List, linux-kernel, dvyukov

On Wed, 15 Jun 2022 at 23:17, Paul E. McKenney <[email protected]> wrote:
>
> On Wed, Jun 15, 2022 at 01:40:39PM -0700, Paul E. McKenney wrote:
> > On Thu, Jun 16, 2022 at 04:26:16AM +0800, kernel test robot wrote:
> > > tree:   https://github.com/ammarfaizi2/linux-block paulmck/linux-rcu/pmladek.2022.06.15a
> > > head:   0ba7324b44282870af740a5a121add62c7f5f730
> > > commit: db21b02f8044e812f8a5e3811f602409290e3ede [133/140] context_tracking: Convert state to atomic_t
> > > config: x86_64-randconfig-r003-20220516 (https://download.01.org/0day-ci/archive/20220616/[email protected]/config)
> > > compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
> > > reproduce (this is a W=1 build):
> > >         # https://github.com/ammarfaizi2/linux-block/commit/db21b02f8044e812f8a5e3811f602409290e3ede
> > >         git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
> > >         git fetch --no-tags ammarfaizi2-block paulmck/linux-rcu/pmladek.2022.06.15a
> > >         git checkout db21b02f8044e812f8a5e3811f602409290e3ede
> > >         # save the config file
> > >         mkdir build_dir && cp config build_dir/.config
> > >         make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> > >
> > > If you fix the issue, kindly add following tag where applicable
> > > Reported-by: kernel test robot <[email protected]>
> > >
> > > All warnings (new ones prefixed by >>):
> > >
> > > >> 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
> >
> > Marco, Dmitry, my guess is that this is due to the ct->active check in
> > both functions.  Are we supposed to do something to make this sort of
> > thing safe for KASAN?
>
> This time actually CCing Marco and Dmitry...

It's due to the atomic_read()s within the noinstr function. Within
noinstr you can use arch_atomic_read() to avoid the instrumentation.

Thanks,
-- Marco

^ permalink raw reply	[flat|nested] 8+ messages in thread

* 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
  2022-06-16  8:19     ` Marco Elver
@ 2022-06-16 13:40       ` Paul E. McKenney
  2022-06-16 16:44         ` Paul E. McKenney
  0 siblings, 1 reply; 8+ messages in thread
From: Paul E. McKenney @ 2022-06-16 13:40 UTC (permalink / raw)
  To: Marco Elver
  Cc: kernel test robot, Frederic Weisbecker, kbuild-all,
	GNU/Weeb Mailing List, linux-kernel, dvyukov

On Thu, Jun 16, 2022 at 10:19:18AM +0200, Marco Elver wrote:
> On Wed, 15 Jun 2022 at 23:17, Paul E. McKenney <[email protected]> wrote:
> >
> > On Wed, Jun 15, 2022 at 01:40:39PM -0700, Paul E. McKenney wrote:
> > > On Thu, Jun 16, 2022 at 04:26:16AM +0800, kernel test robot wrote:
> > > > tree:   https://github.com/ammarfaizi2/linux-block paulmck/linux-rcu/pmladek.2022.06.15a
> > > > head:   0ba7324b44282870af740a5a121add62c7f5f730
> > > > commit: db21b02f8044e812f8a5e3811f602409290e3ede [133/140] context_tracking: Convert state to atomic_t
> > > > config: x86_64-randconfig-r003-20220516 (https://download.01.org/0day-ci/archive/20220616/[email protected]/config)
> > > > compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
> > > > reproduce (this is a W=1 build):
> > > >         # https://github.com/ammarfaizi2/linux-block/commit/db21b02f8044e812f8a5e3811f602409290e3ede
> > > >         git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
> > > >         git fetch --no-tags ammarfaizi2-block paulmck/linux-rcu/pmladek.2022.06.15a
> > > >         git checkout db21b02f8044e812f8a5e3811f602409290e3ede
> > > >         # save the config file
> > > >         mkdir build_dir && cp config build_dir/.config
> > > >         make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> > > >
> > > > If you fix the issue, kindly add following tag where applicable
> > > > Reported-by: kernel test robot <[email protected]>
> > > >
> > > > All warnings (new ones prefixed by >>):
> > > >
> > > > >> 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
> > >
> > > Marco, Dmitry, my guess is that this is due to the ct->active check in
> > > both functions.  Are we supposed to do something to make this sort of
> > > thing safe for KASAN?
> >
> > This time actually CCing Marco and Dmitry...
> 
> 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!

							Thanx, Paul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* 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
  2022-06-16 13:40       ` Paul E. McKenney
@ 2022-06-16 16:44         ` Paul E. McKenney
  2022-06-16 17:32           ` Marco Elver
  0 siblings, 1 reply; 8+ messages in thread
From: Paul E. McKenney @ 2022-06-16 16:44 UTC (permalink / raw)
  To: Marco Elver
  Cc: kernel test robot, Frederic Weisbecker, kbuild-all,
	GNU/Weeb Mailing List, linux-kernel, dvyukov

On Thu, Jun 16, 2022 at 06:40:21AM -0700, Paul E. McKenney wrote:
> On Thu, Jun 16, 2022 at 10:19:18AM +0200, Marco Elver wrote:
> > On Wed, 15 Jun 2022 at 23:17, Paul E. McKenney <[email protected]> wrote:
> > >
> > > On Wed, Jun 15, 2022 at 01:40:39PM -0700, Paul E. McKenney wrote:
> > > > On Thu, Jun 16, 2022 at 04:26:16AM +0800, kernel test robot wrote:
> > > > > tree:   https://github.com/ammarfaizi2/linux-block paulmck/linux-rcu/pmladek.2022.06.15a
> > > > > head:   0ba7324b44282870af740a5a121add62c7f5f730
> > > > > commit: db21b02f8044e812f8a5e3811f602409290e3ede [133/140] context_tracking: Convert state to atomic_t
> > > > > config: x86_64-randconfig-r003-20220516 (https://download.01.org/0day-ci/archive/20220616/[email protected]/config)
> > > > > compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
> > > > > reproduce (this is a W=1 build):
> > > > >         # https://github.com/ammarfaizi2/linux-block/commit/db21b02f8044e812f8a5e3811f602409290e3ede
> > > > >         git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
> > > > >         git fetch --no-tags ammarfaizi2-block paulmck/linux-rcu/pmladek.2022.06.15a
> > > > >         git checkout db21b02f8044e812f8a5e3811f602409290e3ede
> > > > >         # save the config file
> > > > >         mkdir build_dir && cp config build_dir/.config
> > > > >         make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> > > > >
> > > > > If you fix the issue, kindly add following tag where applicable
> > > > > Reported-by: kernel test robot <[email protected]>
> > > > >
> > > > > All warnings (new ones prefixed by >>):
> > > > >
> > > > > >> 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
> > > >
> > > > Marco, Dmitry, my guess is that this is due to the ct->active check in
> > > > both functions.  Are we supposed to do something to make this sort of
> > > > thing safe for KASAN?
> > >
> > > This time actually CCing Marco and Dmitry...
> > 
> > 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.

							Thanx, Paul

------------------------------------------------------------------------

commit 81e24ca26ee9933bcacf67a61e3f6ae41a025442
Author: Paul E. McKenney <[email protected]>
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 <[email protected]>
    Cc: Frederic Weisbecker <[email protected]>
    Cc: Marco Elver <[email protected]>

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
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* 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
  2022-06-16 16:44         ` Paul E. McKenney
@ 2022-06-16 17:32           ` Marco Elver
  2022-06-16 17:49             ` Paul E. McKenney
  0 siblings, 1 reply; 8+ messages in thread
From: Marco Elver @ 2022-06-16 17:32 UTC (permalink / raw)
  To: paulmck
  Cc: kernel test robot, Frederic Weisbecker, kbuild-all,
	GNU/Weeb Mailing List, linux-kernel, dvyukov

On Thu, 16 Jun 2022 at 18:44, Paul E. McKenney <[email protected]> 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.

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.

Reviewed-by: Marco Elver <[email protected]>

>                                                         Thanx, Paul
>
> ------------------------------------------------------------------------
>
> commit 81e24ca26ee9933bcacf67a61e3f6ae41a025442
> Author: Paul E. McKenney <[email protected]>
> 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 <[email protected]>
>     Cc: Frederic Weisbecker <[email protected]>
>     Cc: Marco Elver <[email protected]>
>
> 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
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* 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
  2022-06-16 17:32           ` Marco Elver
@ 2022-06-16 17:49             ` Paul E. McKenney
  0 siblings, 0 replies; 8+ messages in thread
From: Paul E. McKenney @ 2022-06-16 17:49 UTC (permalink / raw)
  To: Marco Elver
  Cc: kernel test robot, Frederic Weisbecker, kbuild-all,
	GNU/Weeb Mailing List, linux-kernel, dvyukov

On Thu, Jun 16, 2022 at 07:32:14PM +0200, Marco Elver wrote:
> On Thu, 16 Jun 2022 at 18:44, Paul E. McKenney <[email protected]> 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 <[email protected]>

Applied, thank you!

                                                         Thanx, Paul

> > ------------------------------------------------------------------------
> >
> > commit 81e24ca26ee9933bcacf67a61e3f6ae41a025442
> > Author: Paul E. McKenney <[email protected]>
> > 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 <[email protected]>
> >     Cc: Frederic Weisbecker <[email protected]>
> >     Cc: Marco Elver <[email protected]>
> >
> > 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
> >

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-16 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-15 20:26 [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 kernel test robot
2022-06-15 20:40 ` Paul E. McKenney
2022-06-15 21:17   ` Paul E. McKenney
2022-06-16  8:19     ` Marco Elver
2022-06-16 13:40       ` Paul E. McKenney
2022-06-16 16:44         ` Paul E. McKenney
2022-06-16 17:32           ` Marco Elver
2022-06-16 17:49             ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox