Skip to content

Commit 2809606

Browse files
hfreudehcahca
authored andcommitted
s390/archrandom: add parameter check for s390_arch_random_generate
A review of the code showed, that this function which is exposed within the whole kernel should do a parameter check for the amount of bytes requested. If this requested bytes is too high an unsigned int overflow could happen causing this function to try to memcpy a really big memory chunk. This is not a security issue as there are only two invocations of this function from arch/s390/include/asm/archrandom.h and both are not exposed to userland. Reported-by: Sven Schnelle <[email protected]> Signed-off-by: Harald Freudenberger <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 70fac80 commit 2809606

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/s390/crypto/arch_random.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ static DECLARE_DELAYED_WORK(arch_rng_work, arch_rng_refill_buffer);
5454

5555
bool s390_arch_random_generate(u8 *buf, unsigned int nbytes)
5656
{
57+
/* max hunk is ARCH_RNG_BUF_SIZE */
58+
if (nbytes > ARCH_RNG_BUF_SIZE)
59+
return false;
60+
5761
/* lock rng buffer */
5862
if (!spin_trylock(&arch_rng_lock))
5963
return false;

0 commit comments

Comments
 (0)