]> git.baikalelectronics.ru Git - kernel.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)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 6 Nov 2014 15:10:22 +0000 (23:10 +0800)
commitd86e70959c12c5bb5fe36fd2661b0a31ca157e02
treea1194d334760f049164a46ceac026e5628f1a2b0
parent3607b378615f045937732d228341c8637077a289
hwrng: pseries - port to new read API and fix stack corruption

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 35a1bf89e15b0a6e5ded84a901c3c477709a2ec2
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.

Cc: stable@vger.kernel.org
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/pseries-rng.c