]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwrng: pseries - port to new read API and fix stack corruption
authorGreg Kurz <gkurz@linux.vnet.ibm.com>
Fri, 31 Oct 2014 06:50:11 +0000 (07:50 +0100)
committerJiri Slaby <jslaby@suse.cz>
Wed, 19 Nov 2014 17:38:15 +0000 (18:38 +0100)
commit50e52368e667f2a8d5a43c0c9f60b4391a5bc715
tree5a9767bf5db43d8e5cef76851940aff44f6ecfc5
parente5fbc698350a42a56f5c165dbb6283d69b65d3f3
hwrng: pseries - port to new read API and fix stack corruption

commit 24c65bc7037e7d0f362c0df70d17dd72ee64b8b9 upstream.

The add_early_randomness() function in drivers/char/hw_random/core.c passes
a 16-byte buffer to pseries_rng_data_read(). Unfortunately, plpar_hcall()
returns four 64-bit values and trashes 16 bytes on the stack.

This bug has been lying around for a long time. It got unveiled by:

commit d3cc7996473a7bdd33256029988ea690754e4e2a
Author: Amit Shah <amit.shah@redhat.com>
Date:   Thu Jul 10 15:42:34 2014 +0530

    hwrng: fetch randomness only after device init

It may trig a oops while loading or unloading the pseries-rng module for both
PowerVM and PowerKVM guests.

This patch does two things:
- pass an intermediate well sized buffer to plpar_hcall(). This is acceptalbe
  since we're not on a hot path.
- move to the new read API so that we know the return buffer size for sure.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/char/hw_random/pseries-rng.c