arm64: futex: Avoid copying out uninitialised stack in failed cmpxchg()

Returning an error code from futex_atomic_cmpxchg_inatomic() indicates
that the caller should not make any use of *uval, and should instead act
upon on the value of the error code. Although this is implemented
correctly in our futex code, we needlessly copy uninitialised stack to
*uval in the error case, which can easily be avoided.

Signed-off-by: Will Deacon <will.deacon@arm.com>
This commit is contained in:
Will Deacon 2019-04-10 11:49:11 +01:00
parent 03110a5cb2
commit 8e4e0ac02b

View File

@ -134,7 +134,9 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
: "memory");
uaccess_disable();
*uval = val;
if (!ret)
*uval = val;
return ret;
}