[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4d7c00d5-f42f-1eff-c5c5-34903f342d40@c-s.fr>
Date: Thu, 18 Oct 2018 11:19:36 +0200
From: Christophe LEROY <christophe.leroy@....fr>
To: Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] powerpc/uaccess: fix warning/error with access_ok()
Le 18/10/2018 à 10:48, Christophe Leroy a écrit :
> With the following peace of code, the following compilation warning
> is encountered:
>
> if (_IOC_DIR(ioc) != _IOC_NONE) {
> int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
>
> if (!access_ok(verify, ioarg, _IOC_SIZE(ioc))) {
>
> drivers/platform/test/dev.c: In function ‘my_ioctl’:
> drivers/platform/test/dev.c:219:7: warning: unused variable ‘verify’ [-Wunused-variable]
> int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
>
> This patch fixes it by handing the type to __access_ok(), changing it
> to an inline function for PPC64 as already done for PPC32
Oops, not that easy, there are places using __access_ok() directly,
those need to be modified as well.
Christophe
>
> Signed-off-by: Christophe Leroy <christophe.leroy@....fr>
> ---
> arch/powerpc/include/asm/uaccess.h | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
> index 15bea9a0f260..97faf0353919 100644
> --- a/arch/powerpc/include/asm/uaccess.h
> +++ b/arch/powerpc/include/asm/uaccess.h
> @@ -47,13 +47,16 @@ static inline void set_fs(mm_segment_t fs)
> * This check is sufficient because there is a large enough
> * gap between user addresses and the kernel addresses
> */
> -#define __access_ok(addr, size, segment) \
> - (((addr) <= (segment).seg) && ((size) <= (segment).seg))
> +static inline int __access_ok(int type, unsigned long addr, unsigned long size,
> + mm_segment_t seg)
> +{
> + return addr <= seg.seg && size <= seg.seg;
> +}
>
> #else
>
> -static inline int __access_ok(unsigned long addr, unsigned long size,
> - mm_segment_t seg)
> +static inline int __access_ok(int type, unsigned long addr, unsigned long size,
> + mm_segment_t seg)
> {
> if (addr > seg.seg)
> return 0;
> @@ -64,7 +67,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size,
>
> #define access_ok(type, addr, size) \
> (__chk_user_ptr(addr), \
> - __access_ok((__force unsigned long)(addr), (size), get_fs()))
> + __access_ok((type), (__force unsigned long)(addr), (size), get_fs()))
>
> /*
> * These are the main single-value transfer routines. They automatically
>
Powered by blists - more mailing lists