* [PATCH] riscv: uaccess: fix __put_user_nocheck for unaligned accesses
@ 2025-07-24 22:08 Aurelien Jarno
2025-07-25 13:42 ` Alexandre Ghiti
2025-08-06 17:15 ` patchwork-bot+linux-riscv
0 siblings, 2 replies; 3+ messages in thread
From: Aurelien Jarno @ 2025-07-24 22:08 UTC (permalink / raw)
To: linux-kernel, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Clément Léger,
open list:RISC-V ARCHITECTURE
Cc: Aurelien Jarno
The type of the value to write should be determined by the size of the
destination, not by the value itself, which may be a constant. This
aligns the behavior with x86_64, where __typeof__(*(__gu_ptr)) is used
to infer the correct type.
This fixes an issue in put_cmsg, which was only writing 4 out of 8
bytes to the cmsg_len field, causing the glibc tst-socket-timestamp test
to fail.
Fixes: ca1a66cdd685 ("riscv: uaccess: do not do misaligned accesses in get/put_user()")
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
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 b88a6218b7f24..22e3f52a763d1 100644
--- a/arch/riscv/include/asm/uaccess.h
+++ b/arch/riscv/include/asm/uaccess.h
@@ -311,7 +311,7 @@ do { \
do { \
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && \
!IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) { \
- __inttype(x) ___val = (__inttype(x))x; \
+ __typeof__(*(__gu_ptr)) ___val = (x); \
if (__asm_copy_to_user_sum_enabled(__gu_ptr, &(___val), sizeof(*__gu_ptr))) \
goto label; \
break; \
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: uaccess: fix __put_user_nocheck for unaligned accesses
2025-07-24 22:08 [PATCH] riscv: uaccess: fix __put_user_nocheck for unaligned accesses Aurelien Jarno
@ 2025-07-25 13:42 ` Alexandre Ghiti
2025-08-06 17:15 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Ghiti @ 2025-07-25 13:42 UTC (permalink / raw)
To: Aurelien Jarno, linux-kernel, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Clément Léger, open list:RISC-V ARCHITECTURE
Hi Aurélien,
On 7/25/25 00:08, Aurelien Jarno wrote:
> The type of the value to write should be determined by the size of the
> destination, not by the value itself, which may be a constant. This
> aligns the behavior with x86_64, where __typeof__(*(__gu_ptr)) is used
> to infer the correct type.
>
> This fixes an issue in put_cmsg, which was only writing 4 out of 8
> bytes to the cmsg_len field, causing the glibc tst-socket-timestamp test
> to fail.
>
> Fixes: ca1a66cdd685 ("riscv: uaccess: do not do misaligned accesses in get/put_user()")
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> 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 b88a6218b7f24..22e3f52a763d1 100644
> --- a/arch/riscv/include/asm/uaccess.h
> +++ b/arch/riscv/include/asm/uaccess.h
> @@ -311,7 +311,7 @@ do { \
> do { \
> if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && \
> !IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) { \
> - __inttype(x) ___val = (__inttype(x))x; \
> + __typeof__(*(__gu_ptr)) ___val = (x); \
> if (__asm_copy_to_user_sum_enabled(__gu_ptr, &(___val), sizeof(*__gu_ptr))) \
> goto label; \
> break; \
Thanks for catching this (I will add the glibc testsuite to our CI).
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Thanks,
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: uaccess: fix __put_user_nocheck for unaligned accesses
2025-07-24 22:08 [PATCH] riscv: uaccess: fix __put_user_nocheck for unaligned accesses Aurelien Jarno
2025-07-25 13:42 ` Alexandre Ghiti
@ 2025-08-06 17:15 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-08-06 17:15 UTC (permalink / raw)
To: Aurelien Jarno
Cc: linux-riscv, linux-kernel, paul.walmsley, palmer, aou, alex,
cleger
Hello:
This patch was applied to riscv/linux.git (for-next)
by Alexandre Ghiti <alexghiti@rivosinc.com>:
On Fri, 25 Jul 2025 00:08:52 +0200 you wrote:
> The type of the value to write should be determined by the size of the
> destination, not by the value itself, which may be a constant. This
> aligns the behavior with x86_64, where __typeof__(*(__gu_ptr)) is used
> to infer the correct type.
>
> This fixes an issue in put_cmsg, which was only writing 4 out of 8
> bytes to the cmsg_len field, causing the glibc tst-socket-timestamp test
> to fail.
>
> [...]
Here is the summary with links:
- riscv: uaccess: fix __put_user_nocheck for unaligned accesses
https://git.kernel.org/riscv/c/a10ce19d93c9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-06 17:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 22:08 [PATCH] riscv: uaccess: fix __put_user_nocheck for unaligned accesses Aurelien Jarno
2025-07-25 13:42 ` Alexandre Ghiti
2025-08-06 17:15 ` 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;
as well as URLs for NNTP newsgroup(s).