]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
riscv/futex: sign extend compare value in atomic cmpxchg
authorAndreas Schwab <schwab@suse.de>
Mon, 3 Feb 2025 10:06:00 +0000 (11:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Mar 2025 17:25:44 +0000 (18:25 +0100)
commitac354e54dcab1c15addf2c8a540b33b081a0abb4
treee0e1820a75510d9987846e253cd5d7934d86016b
parentec9acbab2ea787ef45e46679c62b656912c605b5
riscv/futex: sign extend compare value in atomic cmpxchg

commit 599c44cd21f4967774e0acf58f734009be4aea9a upstream.

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@suse.de>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/mvmfrkv2vhz.fsf@suse.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/riscv/include/asm/futex.h