[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mhng-33b9aafc-448a-4400-9a06-cb222724363a@palmer-ri-x1c9>
Date: Thu, 29 Dec 2022 09:31:27 -0800 (PST)
From: Palmer Dabbelt <palmer@...belt.com>
To: ben-linux@...ff.org
CC: linux-riscv@...ts.infradead.org,
Paul Walmsley <paul.walmsley@...ive.com>,
linux-kernel@...r.kernel.org, aou@...s.berkeley.edu,
ben-linux@...ff.org
Subject: Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@...ff.org wrote:
> If the get_user(x, ptr) has x as a pointer, then the setting
> of (x) = 0 is going to produce the following sparse warning,
> so fix this by forcing the type of 'x' when access_ok() fails.
>
> fs/aio.c:2073:21: warning: Using plain integer as NULL pointer
>
> Signed-off-by: Ben Dooks <ben-linux@...ff.org>
> ---
> arch/riscv/include/asm/uaccess.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> index 855450bed9f5..ec0cab9fbddd 100644
> --- a/arch/riscv/include/asm/uaccess.h
> +++ b/arch/riscv/include/asm/uaccess.h
> @@ -165,7 +165,7 @@ do { \
> might_fault(); \
> access_ok(__p, sizeof(*__p)) ? \
> __get_user((x), __p) : \
> - ((x) = 0, -EFAULT); \
> + ((x) = (__force __typeof__(x))0, -EFAULT); \
> })
>
> #define __put_user_asm(insn, x, ptr, err) \
Looks like arm64 has a pretty similar pattern. They've got the __force
__typeof__ already, but given the similarity it might be worth
refactoring these to share the error checking code.
Reviewed-by: Palmer Dabbelt <palmer@...osinc.com>
I'll give this a bit of time like usual, unless anyone's opposed I'll
put it on fixes. I wasn't planning on sending a PR this week anyway due
to the holidays.
Thanks!
Powered by blists - more mailing lists