Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1581432

Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck()

From Christian Borntraeger <borntraeger@de.ibm.com>
Newsgroups linux.kernel
Subject Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck()
Date 2017-02-15 17:30 +0100
Message-ID <tbaCR-2in-1@gated-at.bofh.it> (permalink)
References <taUoq-8bx-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 02/15/2017 12:03 AM, Arnd Bergmann wrote:
> 
> -#define WRITE_ONCE(x, val) \
> -({							\
> -	union { typeof(x) __val; char __c[1]; } __u =	\
> -		{ .__val = (__force typeof(x)) (val) }; \
> -	__write_once_size(&(x), __u.__c, sizeof(x));	\
> -	__u.__val;					\
> -})
> +#define WRITE_ONCE(x, val)								\
> +(											\
> +	__builtin_choose_expr(sizeof(x) == 1, *(volatile typeof(&(x)))&(x) = (val),	\
> +	__builtin_choose_expr(sizeof(x) == 2, *(volatile typeof(&(x)))&(x) = (val),	\
> +	__builtin_choose_expr(sizeof(x) == 4, *(volatile typeof(&(x)))&(x) = (val),	\
> +	__builtin_choose_expr(sizeof(x) == sizeof(long), *(volatile typeof(&(x)))&(x) = (val),	\

Have you run sparse on those changes?
IIRC we had to add the __force to get rid of address space annotations
in that macro above. Cannot tell if we need something like that here.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck() Arnd Bergmann <arnd@arndb.de> - 2017-02-15 00:10 +0100
  Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck() Dmitry Vyukov <dvyukov@google.com> - 2017-02-15 10:20 +0100
    Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck() Arnd Bergmann <arnd@arndb.de> - 2017-02-15 11:40 +0100
      Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck() Arnd Bergmann <arnd@arndb.de> - 2017-02-15 23:40 +0100
  Re: [RFC] kasan stack overflow warnings again: READ_ONCE(),  typecheck() Christian Borntraeger <borntraeger@de.ibm.com> - 2017-02-15 17:30 +0100
    Re: [RFC] kasan stack overflow warnings again: READ_ONCE(),  typecheck() Christian Borntraeger <borntraeger@de.ibm.com> - 2017-02-15 17:30 +0100
      Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck() Arnd Bergmann <arnd@arndb.de> - 2017-02-15 23:20 +0100

csiph-web