lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87jza7oxep.fsf@all.your.base.are.belong.to.us>
Date: Mon, 03 Feb 2025 16:33:50 +0100
From: Björn Töpel <bjorn@...nel.org>
To: Andreas Schwab <schwab@...e.de>, linux-riscv@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg

Andreas Schwab <schwab@...e.de> writes:

> Make sure the compare value in the lr/sc loop is sign extended to match
> what lr.w does.  Fortunately, due to the compiler keeping the register
> contents sign extended anyway the lack of the explicit extension didn't
> result in wrong code so far, but this cannot be relied upon.
>
> Fixes: b90edb33010b ("RISC-V: Add futex support.")
> Signed-off-by: Andreas Schwab <schwab@...e.de>

Hmm, in this scenario we *can* rely on it, no (inline vs macro)?

Regardless, having an explicit cast there doesn't hurt, and make it more
obvious!

Reviewed-by: Björn Töpel <bjorn@...osinc.com>

Let's add a link to Jessica's comment as well:
Link: https://lore.kernel.org/linux-riscv/CC2D9220-F8DE-4CC8-ACAD-7B1A21E276FE@jrtc27.com/

> ---
>  arch/riscv/include/asm/futex.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/futex.h b/arch/riscv/include/asm/futex.h
> index fc8130f995c1..6907c456ac8c 100644
> --- a/arch/riscv/include/asm/futex.h
> +++ b/arch/riscv/include/asm/futex.h
> @@ -93,7 +93,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
>  		_ASM_EXTABLE_UACCESS_ERR(1b, 3b, %[r])	\
>  		_ASM_EXTABLE_UACCESS_ERR(2b, 3b, %[r])	\
>  	: [r] "+r" (ret), [v] "=&r" (val), [u] "+m" (*uaddr), [t] "=&r" (tmp)
> -	: [ov] "Jr" (oldval), [nv] "Jr" (newval)
> +	: [ov] "Jr" ((long)(int)oldval), [nv] "Jr" (newval)
>  	: "memory");
>  	__disable_user_access();
>  
> -- 
> 2.48.1
>
>
> -- 
> Andreas Schwab, SUSE Labs, schwab@...e.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ