arm64: futex: Restore oldval initialization to work around buggy compilers
Subsystems (2)
PATCH 1/1 arm64: futex: Restore oldval initialization to work around buggy compilers
Commit 045afc24124d ("arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value") removed oldval's zero initialization in arch_futex_atomic_op_inuser because it is not necessary. Unfortunately, Android's arm64 GCC 4.9.4 [1] does not agree:
../kernel/futex.c: In function 'do_futex':../kernel/futex.c:1658:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]
return oldval == cmparg;
^
In file included from ../kernel/futex.c:73:0:
../arch/arm64/include/asm/futex.h:53:6: note: 'oldval' was declared here
int oldval, ret, tmp;
^GCC fails to follow that when ret is non-zero, futex_atomic_op_inuser returns right away, avoiding the uninitialized use that it claims. Restoring the zero initialization works around this issue.
[1]: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
--- arch/arm64/include/asm/futex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/futex.h +1 -1
@@ -50,7 +50,7 @@ do { \static inline int arch_futex_atomic_op_inuser (int op,int oparg,int *oval,u32 __user *_uaddr) { -int oldval, ret, tmp; +int oldval =0 , ret, tmp;u32 __user *uaddr =__uaccess_mask_ptr (_uaddr);pagefault_disable ();
Signature · 1 line
2.21.0
Quoted 19 lines · Nathan Chancellor
Commit
045afc24124d("arm64: futex: FixFUTEX_WAKE_OPatomic ops with non-zero result value") removed oldval's zero initialization inarch_futex_atomic_op_inuserbecause it is not necessary. Unfortunately, Android's arm64 GCC 4.9.4 [1] does not agree:
../kernel/futex.c: In function 'do_futex':../kernel/futex.c:1658:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]return oldval == cmparg; ^ In file included from ../kernel/futex.c:73:0: ../arch/arm64/include/asm/futex.h:53:6: note: 'oldval' was declared here int oldval, ret, tmp; ^GCC fails to follow that when ret is non-zero,
futex_atomic_op_inuserreturns right away, avoiding the uninitialized use that it claims. Restoring the zero initialization works around this issue.
Quoted 5 lines
[1]: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
Fixes 045afc24124d ("arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value")Signed-off-by Nathan Chancellor <[email protected]>
Catalin Marinas
maintainerQuoted 19 lines · Nathan Chancellor
Commit
045afc24124d("arm64: futex: FixFUTEX_WAKE_OPatomic ops with non-zero result value") removed oldval's zero initialization inarch_futex_atomic_op_inuserbecause it is not necessary. Unfortunately, Android's arm64 GCC 4.9.4 [1] does not agree:
../kernel/futex.c: In function 'do_futex':../kernel/futex.c:1658:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]return oldval == cmparg; ^ In file included from ../kernel/futex.c:73:0: ../arch/arm64/include/asm/futex.h:53:6: note: 'oldval' was declared here int oldval, ret, tmp; ^GCC fails to follow that when ret is non-zero,
futex_atomic_op_inuserreturns right away, avoiding the uninitialized use that it claims. Restoring the zero initialization works around this issue.
Quoted 5 lines
[1]: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
Fixes 045afc24124d ("arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value")Signed-off-by Nathan Chancellor <[email protected]>
Thanks. That compiler version doesn't seem very smart. I'll queue this for -rc6.
Signature · 1 line
Catalin