[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fa6f5e3c-3452-41ff-ab81-60f5f31ff797@ghiti.fr>
Date: Fri, 25 Jul 2025 15:42:15 +0200
From: Alexandre Ghiti <alex@...ti.fr>
To: Aurelien Jarno <aurelien@...el32.net>, linux-kernel@...r.kernel.org,
Paul Walmsley <paul.walmsley@...ive.com>, Palmer Dabbelt
<palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Clément Léger <cleger@...osinc.com>,
"open list:RISC-V ARCHITECTURE" <linux-riscv@...ts.infradead.org>
Subject: Re: [PATCH] riscv: uaccess: fix __put_user_nocheck for unaligned
accesses
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@...el32.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@...osinc.com>
Thanks,
Alex
Powered by blists - more mailing lists