2022-09-07 17:56:53

by Marco Elver

[permalink] [raw]
Subject: [PATCH 2/2] objtool, kcsan: Add volatile read/write instrumentation to whitelist

Adds KCSAN's volatile barrier instrumentation to objtool's uaccess
whitelist.

Recent kernel change have shown that this was missing from the uaccess
whitelist (since the first upstreamed version of KCSAN):

mm/gup.o: warning: objtool: fault_in_readable+0x101: call to __tsan_volatile_write1() with UACCESS enabled

Fixes: 75d75b7a4d54 ("kcsan: Support distinguishing volatile accesses")
Signed-off-by: Marco Elver <[email protected]>
---
tools/objtool/check.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e55fdf952a3a..67afdce3421f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -999,6 +999,16 @@ static const char *uaccess_safe_builtin[] = {
"__tsan_read_write4",
"__tsan_read_write8",
"__tsan_read_write16",
+ "__tsan_volatile_read1",
+ "__tsan_volatile_read2",
+ "__tsan_volatile_read4",
+ "__tsan_volatile_read8",
+ "__tsan_volatile_read16",
+ "__tsan_volatile_write1",
+ "__tsan_volatile_write2",
+ "__tsan_volatile_write4",
+ "__tsan_volatile_write8",
+ "__tsan_volatile_write16",
"__tsan_atomic8_load",
"__tsan_atomic16_load",
"__tsan_atomic32_load",
--
2.37.2.789.g6183377224-goog


2022-09-07 18:23:42

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH 2/2] objtool, kcsan: Add volatile read/write instrumentation to whitelist

On Wed, 7 Sept 2022 at 19:42, Boqun Feng <[email protected]> wrote:
>
> On Wed, Sep 07, 2022 at 07:39:03PM +0200, Marco Elver wrote:
> > Adds KCSAN's volatile barrier instrumentation to objtool's uaccess
>
> Confused. Are things like "__tsan_volatile_read4" considered as
> "barrier" for KCSAN?

No, it's what's emitted for READ_ONCE() and WRITE_ONCE().

Thanks,
-- Marco

2022-09-07 18:30:03

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH 2/2] objtool, kcsan: Add volatile read/write instrumentation to whitelist

On Wed, 7 Sept 2022 at 19:45, Boqun Feng <[email protected]> wrote:
>
> On Wed, Sep 07, 2022 at 07:43:32PM +0200, Marco Elver wrote:
> > On Wed, 7 Sept 2022 at 19:42, Boqun Feng <[email protected]> wrote:
> > >
> > > On Wed, Sep 07, 2022 at 07:39:03PM +0200, Marco Elver wrote:
> > > > Adds KCSAN's volatile barrier instrumentation to objtool's uaccess
> > >
> > > Confused. Are things like "__tsan_volatile_read4" considered as
> > > "barrier" for KCSAN?
> >
> > No, it's what's emitted for READ_ONCE() and WRITE_ONCE().
> >
>
> Thanks for clarification, then I guess better to remove the word
> "barrier" in the commit log?

Yes, that'd be best. (I think it was a copy/paste error.)

Thanks,
-- Marco

2022-09-07 18:33:20

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH 2/2] objtool, kcsan: Add volatile read/write instrumentation to whitelist

On Wed, 7 Sept 2022 at 19:43, Marco Elver <[email protected]> wrote:
>
> On Wed, 7 Sept 2022 at 19:42, Boqun Feng <[email protected]> wrote:
> >
> > On Wed, Sep 07, 2022 at 07:39:03PM +0200, Marco Elver wrote:
> > > Adds KCSAN's volatile barrier instrumentation to objtool's uaccess
> >
> > Confused. Are things like "__tsan_volatile_read4" considered as
> > "barrier" for KCSAN?
>
> No, it's what's emitted for READ_ONCE() and WRITE_ONCE().

And you rightly pointed out there's a mistake in the commit message I
just saw. :-)

If there's no v2, Paul, kindly perform a s/barrier//.

Thanks,
-- Marco

2022-09-07 18:53:35

by Boqun Feng

[permalink] [raw]
Subject: Re: [PATCH 2/2] objtool, kcsan: Add volatile read/write instrumentation to whitelist

On Wed, Sep 07, 2022 at 07:39:03PM +0200, Marco Elver wrote:
> Adds KCSAN's volatile barrier instrumentation to objtool's uaccess

Confused. Are things like "__tsan_volatile_read4" considered as
"barrier" for KCSAN?

Regards,
Boqun

> whitelist.
>
> Recent kernel change have shown that this was missing from the uaccess
> whitelist (since the first upstreamed version of KCSAN):
>
> mm/gup.o: warning: objtool: fault_in_readable+0x101: call to __tsan_volatile_write1() with UACCESS enabled
>
> Fixes: 75d75b7a4d54 ("kcsan: Support distinguishing volatile accesses")
> Signed-off-by: Marco Elver <[email protected]>
> ---
> tools/objtool/check.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index e55fdf952a3a..67afdce3421f 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -999,6 +999,16 @@ static const char *uaccess_safe_builtin[] = {
> "__tsan_read_write4",
> "__tsan_read_write8",
> "__tsan_read_write16",
> + "__tsan_volatile_read1",
> + "__tsan_volatile_read2",
> + "__tsan_volatile_read4",
> + "__tsan_volatile_read8",
> + "__tsan_volatile_read16",
> + "__tsan_volatile_write1",
> + "__tsan_volatile_write2",
> + "__tsan_volatile_write4",
> + "__tsan_volatile_write8",
> + "__tsan_volatile_write16",
> "__tsan_atomic8_load",
> "__tsan_atomic16_load",
> "__tsan_atomic32_load",
> --
> 2.37.2.789.g6183377224-goog
>

2022-09-07 18:55:43

by Boqun Feng

[permalink] [raw]
Subject: Re: [PATCH 2/2] objtool, kcsan: Add volatile read/write instrumentation to whitelist

On Wed, Sep 07, 2022 at 07:43:32PM +0200, Marco Elver wrote:
> On Wed, 7 Sept 2022 at 19:42, Boqun Feng <[email protected]> wrote:
> >
> > On Wed, Sep 07, 2022 at 07:39:03PM +0200, Marco Elver wrote:
> > > Adds KCSAN's volatile barrier instrumentation to objtool's uaccess
> >
> > Confused. Are things like "__tsan_volatile_read4" considered as
> > "barrier" for KCSAN?
>
> No, it's what's emitted for READ_ONCE() and WRITE_ONCE().
>

Thanks for clarification, then I guess better to remove the word
"barrier" in the commit log?

Regards,
Boqun

> Thanks,
> -- Marco