Skip to content

Commit d5d547a

Browse files
committed
Merge tag 'random-6.11-rc6-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random
Pull random number generator fix from Jason Donenfeld: "Reject invalid flags passed to vgetrandom() in the same way that getrandom() does, so that the behavior is the same, from Yann. The flags argument to getrandom() only has a behavioral effect on the function if the RNG isn't initialized yet, so vgetrandom() falls back to the syscall in that case. But if the RNG is initialized, all of the flags behave the same way, so vgetrandom() didn't bother checking them, and just ignored them entirely. But that doesn't account for invalid flags passed in, which need to be rejected so we can use them later" * tag 'random-6.11-rc6-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random: random: vDSO: reject unknown getrandom() flags
2 parents 928f79a + 28f5df2 commit d5d547a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/vdso/getrandom.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ __cvdso_getrandom_data(const struct vdso_rng_data *rng_info, void *buffer, size_
8585
if (unlikely(((unsigned long)opaque_state & ~PAGE_MASK) + sizeof(*state) > PAGE_SIZE))
8686
return -EFAULT;
8787

88+
/* Handle unexpected flags by falling back to the kernel. */
89+
if (unlikely(flags & ~(GRND_NONBLOCK | GRND_RANDOM | GRND_INSECURE)))
90+
goto fallback_syscall;
91+
8892
/* If the caller passes the wrong size, which might happen due to CRIU, fallback. */
8993
if (unlikely(opaque_len != sizeof(*state)))
9094
goto fallback_syscall;

0 commit comments

Comments
 (0)