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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <5592487D.7080006@intel.com>
Date:	Tue, 30 Jun 2015 15:42:53 +0800
From:	Pan Xinhui <xinhuix.pan@...el.com>
To:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:	akpm@...ux-foundation.org, linux@...musvillemoes.dk, tj@...nel.org,
	peterz@...radead.org, sudeep.holla@....com, mina86@...a86.com,
	yury.norov@...il.com, "mnipxh@....com" <mnipxh@....com>
Subject: [PATCH] lib/bitmap.c: return -EINVAL for grouping errors in __bitmap_parselist

Sometimes the input from user may cause an unexpected result.

just like __bitmap_parse, we return -EINVAL if there is no avaiable digit in each
parsing procedures.

Signed-off-by: Pan Xinhui <xinhuix.pan@...el.com>
---
  lib/bitmap.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/bitmap.c b/lib/bitmap.c
index 64c0926..995fca2 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -504,7 +504,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
  		int nmaskbits)
  {
  	unsigned a, b;
-	int c, old_c, totaldigits;
+	int c, old_c, totaldigits, ndigits;
  	const char __user __force *ubuf = (const char __user __force *)buf;
  	int exp_digit, in_range;
  
@@ -514,6 +514,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
  		exp_digit = 1;
  		in_range = 0;
  		a = b = 0;
+		ndigits = 0;
  
  		/* Get the next cpu# or a range of cpu#'s */
  		while (buflen) {
@@ -555,8 +556,10 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
  			if (!in_range)
  				a = b;
  			exp_digit = 0;
-			totaldigits++;
+			ndigits++; totaldigits++;
  		}
+		if (ndigits == 0)
+			return -EINVAL;
  		if (!(a <= b))
  			return -EINVAL;
  		if (b >= nmaskbits)
-- 
1.9.1
--
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