powerpc/uaccess: Perform barrier_nospec() in KUAP allowance helpers
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Sun, 7 Feb 2021 10:08:11 +0000 (10:08 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 8 Feb 2021 14:10:15 +0000 (01:10 +1100)
commit8524e2e76441fc615a3b5c1415823e051cc79eae
treebb1e0ac0b2a89d748ba13ac69b81ded0ab696120
parent22b89ba178dd0a66a26699ead014a3e73ff8e044
powerpc/uaccess: Perform barrier_nospec() in KUAP allowance helpers

barrier_nospec() in uaccess helpers is there to protect against
speculative accesses around access_ok().

When using user_access_begin() sequences together with
unsafe_get_user() like macros, barrier_nospec() is called for
every single read although we know the access_ok() is done
onece.

Since all user accesses must be granted by a call to either
allow_read_from_user() or allow_read_write_user() which will
always happen after the access_ok() check, move the barrier_nospec()
there.

Reported-by: Christopher M. Riedl <cmr@codefail.de>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/c72f014730823b413528e90ab6c4d3bcb79f8497.1612692067.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/kup.h
arch/powerpc/include/asm/uaccess.h