From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Arnd Bergmann <arnd@arndb.de>, Dmitry Vyukov <dvyukov@google.com>
Cc: "kasan-dev@googlegroups.com" <kasan-dev@googlegroups.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck()
Date: Wed, 15 Feb 2017 17:18:50 +0100 [thread overview]
Message-ID: <30a6c19f-c854-786d-8b36-1825528b64cf@de.ibm.com> (raw)
In-Reply-To: <1745339.Zp71hEDpdI@wuerfel>
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.
next prev parent reply other threads:[~2017-02-15 16:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 23:03 Arnd Bergmann
2017-02-15 9:18 ` Dmitry Vyukov
2017-02-15 10:34 ` Arnd Bergmann
2017-02-15 22:31 ` Arnd Bergmann
2017-02-15 14:06 ` Andrey Ryabinin
2017-02-15 14:19 ` Andrey Ryabinin
2017-02-15 16:18 ` Christian Borntraeger [this message]
2017-02-15 16:20 ` Christian Borntraeger
2017-02-15 22:19 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30a6c19f-c854-786d-8b36-1825528b64cf@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=arnd@arndb.de \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome