lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200416121135.GE4987@lakrids.cambridge.arm.com>
Date:   Thu, 16 Apr 2020 13:11:36 +0100
From:   Mark Rutland <mark.rutland@....com>
To:     Will Deacon <will@...nel.org>
Cc:     linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
        kernel-team@...roid.com, Michael Ellerman <mpe@...erman.id.au>,
        Peter Zijlstra <peterz@...radead.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Segher Boessenkool <segher@...nel.crashing.org>,
        Christian Borntraeger <borntraeger@...ibm.com>,
        Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
        Arnd Bergmann <arnd@...db.de>,
        Peter Oberparleiter <oberpar@...ux.ibm.com>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Robin Murphy <robin.murphy@....com>
Subject: Re: [PATCH v3 05/12] arm64: csum: Disable KASAN for do_csum()

On Thu, Apr 16, 2020 at 12:53:46PM +0100, Will Deacon wrote:
> On Thu, Apr 16, 2020 at 10:31:06AM +0100, Mark Rutland wrote:
> > FWIW, for the arm64 unwind code we could add a helper to snapshot the
> > frame record, and mark that as __no_sanitize_address, e.g.

[...]

> > ... we'd need to do likewied in a few bits of unwind code:

[...]

> Indeed. For now, I'm going to keep this simple with the change below, but
> I'll revisit this later on because I have another series removing
> smp_read_barrier_depends() which makes this a lot simpler.
> 
> Will

The below looks good to me; thanks for putting that together!

Mark.

> 
> --->8
> 
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index 00a68063d9d5..c363d8debc43 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -212,18 +212,12 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
>  	(typeof(x))__x;							\
>  })
>  
> -/*
> - * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need
> - * to hide memory access from KASAN.
> - */
> -#define READ_ONCE_NOCHECK(x)						\
> +#define READ_ONCE(x)							\
>  ({									\
>  	compiletime_assert_rwonce_type(x);				\
>  	__READ_ONCE_SCALAR(x);						\
>  })
>  
> -#define READ_ONCE(x)	READ_ONCE_NOCHECK(x)
> -
>  #define __WRITE_ONCE(x, val)				\
>  do {							\
>  	*(volatile typeof(x) *)&(x) = (val);		\
> @@ -247,6 +241,24 @@ do {							\
>  # define __no_kasan_or_inline __always_inline
>  #endif
>  
> +static __no_kasan_or_inline
> +unsigned long __read_once_word_nocheck(const void *addr)
> +{
> +	return __READ_ONCE(*(unsigned long *)addr);
> +}
> +
> +/*
> + * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a
> + * word from memory atomically but without telling KASAN. This is usually
> + * used by unwinding code when walking the stack of a running process.
> + */
> +#define READ_ONCE_NOCHECK(x)						\
> +({									\
> +	unsigned long __x = __read_once_word_nocheck(&(x));		\
> +	smp_read_barrier_depends();					\
> +	__x;								\
> +})
> +
>  static __no_kasan_or_inline
>  unsigned long read_word_at_a_time(const void *addr)
>  {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ