Skip to content

Commit

Permalink
arm64: futex: Avoid copying out uninitialised stack in failed cmpxchg()
Browse files Browse the repository at this point in the history
commit 8e4e0ac upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Will Deacon authored and Greg Kroah-Hartman committed Jul 3, 2019
1 parent 5a8221b commit 9a53f4f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/arm64/include/asm/futex.h
Original file line number Diff line number Diff line change
@@ -134,7 +134,9 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
: "memory");
uaccess_disable();

*uval = val;
if (!ret)
*uval = val;

return ret;
}

0 comments on commit 9a53f4f

Please sign in to comment.