lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1370808005-23565-2-git-send-email-yinghai@kernel.org>
Date:	Sun,  9 Jun 2013 13:00:05 -0700
From:	Yinghai Lu <yinghai@...nel.org>
To:	"H. Peter Anvin" <hpa@...or.com>,
	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...e.hu>,
	Joshua Covington <joshuacov@...glemail.com>,
	linux-kernel@...r.kernel.org, Yinghai Lu <yinghai@...nel.org>,
	<stable@...r.kernel.org>
Subject: [PATCH 2/2] x86, range: make add_range use blank slot

Now add_range_with_merge will generate blank slot as subtract_range.
we could reach the array limit because of blank slots.

We can let add_range to have second try to use blank slot.

Also use WARN_ONCE to print trace.

Reported-by: Joshua Covington <joshuacov@...glemail.com>
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
Cc: <stable@...r.kernel.org> v3.9
---
 kernel/range.c |   34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

Index: linux-2.6/kernel/range.c
===================================================================
--- linux-2.6.orig/kernel/range.c
+++ linux-2.6/kernel/range.c
@@ -3,23 +3,34 @@
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/bug.h>
 #include <linux/sort.h>
-
 #include <linux/range.h>
 
 int add_range(struct range *range, int az, int nr_range, u64 start, u64 end)
 {
-	if (start >= end)
-		return nr_range;
+	int i;
 
-	/* Out of slots: */
-	if (nr_range >= az)
+	if (start >= end)
 		return nr_range;
 
-	range[nr_range].start = start;
-	range[nr_range].end = end;
+	/* Out of slots ? */
+	if (nr_range < az) {
+		i = nr_range;
+		nr_range++;
+	} else {
+		/* find blank slot */
+		for (i = 0; i < az; i++)
+			if (!range[i].end)
+				break;
+		if (i == az) {
+			WARN_ONCE(1, "run out of slot in ranges\n");
+			return az;
+		}
+	}
 
-	nr_range++;
+	range[i].start = start;
+	range[i].end = end;
 
 	return nr_range;
 }
@@ -98,10 +109,9 @@ void subtract_range(struct range *range,
 			if (i < az) {
 				range[i].end = range[j].end;
 				range[i].start = end;
-			} else {
-				pr_err("%s: run out of slot in ranges\n",
-					__func__);
-			}
+			} else
+				WARN_ONCE(1, "run out of slot in ranges\n");
+
 			range[j].end = start;
 			continue;
 		}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ