Skip to contentSkip to conversation

arch/x86/entry/vdso/vma.c: Use get_random_max32() for vdso_addr

RFC PATCH In review George Spelvin 1 participant 1 message Mar 28, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 49/50 arch/x86/entry/vdso/vma.c: Use get_random_max32() for vdso_addr

Which is faster and more uniform than get_random_int() % range.

Cc Ingo Molnar <[email protected]>
Cc Andy Lutomirski <[email protected]>
---
 arch/x86/entry/vdso/vma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/vdso/vma.c +1 -1
index f5937742b2901..beb4ef8f85987 100644
@@ -227,7 +227,7 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
 	end -= len;
 
 	if (end > start) {
-		offset = get_random_int() % (((end - start) >> PAGE_SHIFT) + 1);
+		offset = get_random_max32(((end - start) >> PAGE_SHIFT) + 1);
 		addr = start + (offset << PAGE_SHIFT);
 	} else {
 		addr = start;
Signature · 1 line
2.26.0