mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Arnd Bergmann <arnd@arndb.de>, Dmitry Vyukov <dvyukov@google.com>
Cc: "kasan-dev@googlegroups.com" <kasan-dev@googlegroups.com>,
	Alexander Potapenko <glider@google.com>,
	<linux-kernel@vger.kernel.org>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: Re: [RFC] kasan stack overflow warnings again: READ_ONCE(), typecheck()
Date: Wed, 15 Feb 2017 17:19:49 +0300	[thread overview]
Message-ID: <d3ed1833-d22f-2501-6820-6de579bf35f0@virtuozzo.com> (raw)
In-Reply-To: <36862803-f365-6ab4-198e-e858f41ee914@virtuozzo.com>



On 02/15/2017 05:06 PM, Andrey Ryabinin wrote:

> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index 10bca12..5d9dd63 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -301,10 +301,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
>   */
>  
>  #define __READ_ONCE(x, check)						\
> -	__builtin_choose_expr(sizeof(x) == 1, *(volatile typeof(&(x)))&(x), \
> -	__builtin_choose_expr(sizeof(x) == 2, *(volatile typeof(&(x)))&(x), \
> -	__builtin_choose_expr(sizeof(x) == 4, *(volatile typeof(&(x)))&(x), \
> -	__builtin_choose_expr(sizeof(x) == sizeof(long), *(volatile typeof(&(x)))&(x), \
> +	__builtin_choose_expr(sizeof(x) == 1, (typeof(x))(__u64)*(volatile __u8 *)&(x), \
> +	__builtin_choose_expr(sizeof(x) == 2, (typeof(x))(__u64)*(volatile __u16 *)&(x), \
> +	__builtin_choose_expr(sizeof(x) == 4, (typeof(x))(__u64)*(volatile __u32 *)&(x), \
> +	__builtin_choose_expr(sizeof(x) == 8, (typeof(x))(__u64)*(volatile __u64 *)&(x), \
>  	({union { typeof(x) __val; char __c[1]; } __u;			\
>  	if (check)							\
>  		__read_once_size(&(x), __u.__c, sizeof(x));		\

Scratch this, it doesn't work:
../arch/x86/mm/gup.c:20:2: error: conversion to non-scalar type requested
  return READ_ONCE(*ptep);
  ^

  reply	other threads:[~2017-02-15 14:18 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 [this message]
2017-02-15 16:18 ` Christian Borntraeger
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=d3ed1833-d22f-2501-6820-6de579bf35f0@virtuozzo.com \
    --to=aryabinin@virtuozzo.com \
    --cc=arnd@arndb.de \
    --cc=borntraeger@de.ibm.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

all inboxes | Powered by JetHome®