]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
arm64: futex: Avoid copying out uninitialised stack in failed cmpxchg()
authorWill Deacon <will.deacon@arm.com>
Wed, 10 Apr 2019 10:49:11 +0000 (11:49 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838824
commit 8e4e0ac02b449297b86498ac24db5786ddd9f647 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm64/include/asm/futex.h

index c7e30a6ed56ee7a5c4f4298d0ba320b6252c5bf6..232917e9c1d9a6b732c0a32e5943ed1f090e7602 100644 (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;
 }