trinity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 7/7] Removed overlapping values in get_interesting_value()
@ 2015-03-04 21:12 tyson.w.smith
  0 siblings, 0 replies; only message in thread
From: tyson.w.smith @ 2015-03-04 21:12 UTC (permalink / raw)
  To: davej; +Cc: trinity, Tyson Smith

From: Tyson Smith <tysmith@motorola.com>

Added 50/50 chance of skipping 64bit modifications code block. This should
likely be closer to 1 in 4 odds of entering this branch, perhaps less if
these values haven't been triggering issues in the past.
---
 interesting-numbers.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/interesting-numbers.c b/interesting-numbers.c
index 4b4e785..aeb0335 100644
--- a/interesting-numbers.c
+++ b/interesting-numbers.c
@@ -95,20 +95,20 @@ unsigned long get_interesting_value(void)
 	low = (rand() & 0xf) ? low : plus_minus_two(low);	// 1 in 16 call plus_minus_two
 #if __WORDSIZE != 32
 
-	switch (rand() % 13) {
-	case 0: return 0;
-	case 1: return low;
-	case 2: return 0x0000000100000000UL | low;
-	case 3: return 0x7fffffff00000000UL | low;
-	case 4: return 0x8000000000000000UL | low;
-	case 5: return 0xffffffff00000000UL | low;
-	case 6: return 0xffffffffffffff00UL | (rand() % 256);
-	case 7: return 0xffffffffffffffffUL - page_size;
-	case 8: return PAGE_OFFSET | (low << 4);
-	case 9: return KERNEL_ADDR | (low & 0xffffff);
-	case 10: return MODULE_ADDR | (low & 0xffffff);
-	case 11: return per_arch_interesting_addr(low);
-	case 12: return (low << 32);
+	if (rand_bool()) {	// FIXME: This should likely be less aggressive than 50/50
+		switch (rand() % 11) {
+		case 0: return 0x0000000100000000UL | low;
+		case 1: return 0x7fffffff00000000UL | low;
+		case 2: return 0x8000000000000000UL | low;
+		case 3: return 0xffffffff00000000UL | low;
+		case 4: return 0xffffffffffffff00UL | (rand() & 0xff);
+		case 5: return 0xffffffffffffffffUL - page_size;
+		case 6: return PAGE_OFFSET | (low << 4);
+		case 7: return KERNEL_ADDR | (low & 0xffffff);
+		case 8: return MODULE_ADDR | (low & 0xffffff);
+		case 9: return per_arch_interesting_addr(low);
+		case 10: return (low << 32);
+		}
 	}
 
 #endif	/* __WORDSIZE */
-- 
1.9.1

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

only message in thread, other threads:[~2015-03-04 21:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-04 21:12 [PATCH 7/7] Removed overlapping values in get_interesting_value() tyson.w.smith

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).