linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1 48/50] arch/arm/kernel/process.c: Use get_random_max32() for sigpage_addr()
@ 2019-11-29 23:57 George Spelvin
  0 siblings, 0 replies; only message in thread
From: George Spelvin @ 2019-11-29 23:57 UTC (permalink / raw)
  To: linux-kernel, lkml
  Cc: Nathan Lynch, Dmitry Safonov, Russell King, linux-arm-kernel

Which is faster and less biased than get_random_int() % range

Signed-off-by: George Spelvin <lkml@sdf.org>
Cc: Nathan Lynch <nathan_lynch@mentor.com>
Cc: Dmitry Safonov <0x7f454c46@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/kernel/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 46e478fb5ea20..9f2556be33505 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -391,7 +391,7 @@ static unsigned long sigpage_addr(const struct mm_struct *mm,
 
 	slots = ((last - first) >> PAGE_SHIFT) + 1;
 
-	offset = get_random_int() % slots;
+	offset = get_random_max32(slots);
 
 	addr = first + (offset << PAGE_SHIFT);
 
-- 
2.26.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-28 16:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 23:57 [RFC PATCH v1 48/50] arch/arm/kernel/process.c: Use get_random_max32() for sigpage_addr() George Spelvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).