* [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
@ 2022-12-29 17:05 Ben Dooks
2022-12-29 17:31 ` Palmer Dabbelt
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ben Dooks @ 2022-12-29 17:05 UTC (permalink / raw)
To: linux-riscv; +Cc: paul.walmsley, palmer, linux-kernel, aou, Ben Dooks
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@fluff.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) \
--
2.39.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
2022-12-29 17:05 [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user() Ben Dooks
@ 2022-12-29 17:31 ` Palmer Dabbelt
2022-12-29 17:34 ` Ben Dooks
2023-01-05 22:52 ` Palmer Dabbelt
2023-01-05 23:00 ` patchwork-bot+linux-riscv
2 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2022-12-29 17:31 UTC (permalink / raw)
To: ben-linux; +Cc: linux-riscv, Paul Walmsley, linux-kernel, aou, ben-linux
On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@fluff.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@fluff.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@rivosinc.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!
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
2022-12-29 17:31 ` Palmer Dabbelt
@ 2022-12-29 17:34 ` Ben Dooks
0 siblings, 0 replies; 5+ messages in thread
From: Ben Dooks @ 2022-12-29 17:34 UTC (permalink / raw)
To: Palmer Dabbelt; +Cc: ben-linux, linux-riscv, Paul Walmsley, linux-kernel, aou
On Thu, Dec 29, 2022 at 09:31:27AM -0800, Palmer Dabbelt wrote:
> On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@fluff.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@fluff.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.
I looked there for an idea on how to fix.
> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.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.
Ok, it's a warning which would be nice to be fixed.
--
Ben Dooks, ben@fluff.org, http://www.fluff.org/ben/
Large Hadron Colada: A large Pina Colada that makes the universe disappear.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
2022-12-29 17:05 [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user() Ben Dooks
2022-12-29 17:31 ` Palmer Dabbelt
@ 2023-01-05 22:52 ` Palmer Dabbelt
2023-01-05 23:00 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 5+ messages in thread
From: Palmer Dabbelt @ 2023-01-05 22:52 UTC (permalink / raw)
To: linux-riscv, Ben Dooks; +Cc: aou, Paul Walmsley, linux-kernel, Palmer Dabbelt
On Thu, 29 Dec 2022 17:05:45 +0000, Ben Dooks 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
>
>
> [...]
Applied, thanks!
[1/1] riscv: uaccess: fix type of 0 variable on error in get_user()
https://git.kernel.org/palmer/c/b9b916aee671
Best regards,
--
Palmer Dabbelt <palmer@rivosinc.com>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
2022-12-29 17:05 [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user() Ben Dooks
2022-12-29 17:31 ` Palmer Dabbelt
2023-01-05 22:52 ` Palmer Dabbelt
@ 2023-01-05 23:00 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-riscv @ 2023-01-05 23:00 UTC (permalink / raw)
To: Ben Dooks; +Cc: linux-riscv, paul.walmsley, palmer, linux-kernel, aou
Hello:
This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:
On Thu, 29 Dec 2022 17:05:45 +0000 you 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@fluff.org>
>
> [...]
Here is the summary with links:
- riscv: uaccess: fix type of 0 variable on error in get_user()
https://git.kernel.org/riscv/c/b9b916aee671
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-06 1:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-29 17:05 [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user() Ben Dooks
2022-12-29 17:31 ` Palmer Dabbelt
2022-12-29 17:34 ` Ben Dooks
2023-01-05 22:52 ` Palmer Dabbelt
2023-01-05 23:00 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox