mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ken@coverity.com
To: linux-kernel@vger.kernel.org
Cc: linux@coverity.com
Subject: [CHECKER] Security reports involving isspace()
Date: Tue, 20 Apr 2004 15:14:21 -0700 (PDT)	[thread overview]
Message-ID: <12837.24.6.86.122.1082499261.spork@webmail.coverity.com> (raw)

Here are some more static analysis reports from Coverity.  These are
places where the kernel gets a scalar from the user and then uses it as an
array index with out bounds checking it.

All of the reports below deal with the isspace macro.  It expands to an
access to a static array with 256 entries.  If we use an unsigned char to
index into the array, there are no problems.  However, when that char is
signed, we can index off the left of the array.

It seems like this isn't a big deal, but if the isspace array is located
after some important data structure, we could leak information.

thanks for your feedback,
Ken Ashcraft
PS - See hundreds of bugs in the Linux kernel found by Coverity:
http://linuxbugs.coverity.com

---------------------------------------------------------
[BUG]
/home/kash/linux/linux-2.6.5/net/sunrpc/sysctl.c:78:proc_dodebug:
ERROR:TAINT: 78:78:Using user value "c" without first performing bounds
checks [SOURCE_MODEL=(lib,__get_user,user,taint)] [PATH=]  [MINOR]


	if (write) {
		if (!access_ok(VERIFY_READ, buffer, left))
			return -EFAULT;
		p = (char *) buffer;

Error --->
		while (left && __get_user(c, p) >= 0 && isspace(c))
			left--, p++;
		if (!left)
			goto done;
---------------------------------------------------------
[BUG]
/home/kash/linux/linux-2.6.5/kernel/sysctl.c:1484:do_proc_dointvec:
ERROR:TAINT: 1482:1484:Using user value "c" without first performing
bounds checks [SOURCE_MODEL=(lib,get_user,user,taint)] [PATH=]  [MINOR]

	}
	if (write) {
		p = (char *) buffer;
		while (left) {
			char c;
Start --->
			if (get_user(c, p++))
				return -EFAULT;
Error --->
			if (!isspace(c))
				break;
			left--;
		}
---------------------------------------------------------
[BUG]
/home/kash/linux/linux-2.6.5/kernel/sysctl.c:1719:do_proc_doulongvec_minmax:
ERROR:TAINT: 1717:1719:Using user value "c" without first performing
bounds checks [SOURCE_MODEL=(lib,get_user,user,taint)] [PATH=]  [MINOR]

	}
	if (write) {
		p = (char *) buffer;
		while (left) {
			char c;
Start --->
			if (get_user(c, p++))
				return -EFAULT;
Error --->
			if (!isspace(c))
				break;
			left--;
		}
---------------------------------------------------------
[BUG]
/home/kash/linux/linux-2.6.5/kernel/sysctl.c:1658:do_proc_doulongvec_minmax:
ERROR:TAINT: 1656:1658:Using user value "c" without first performing
bounds checks [SOURCE_MODEL=(lib,get_user,user,taint)] [PATH=]  [MINOR]


	for (; left && vleft--; i++, min++, max++, first=0) {
		if (write) {
			while (left) {
				char c;
Start --->
				if (get_user(c, (char __user *) buffer))
					return -EFAULT;
Error --->
				if (!isspace(c))
					break;
				left--;
				buffer++;
---------------------------------------------------------
[BUG]
/home/kash/linux/linux-2.6.5/kernel/sysctl.c:1420:do_proc_dointvec:
ERROR:TAINT: 1418:1420:Using user value "c" without first performing
bounds checks [SOURCE_MODEL=(lib,get_user,user,taint)] [PATH=]  [MINOR]


	for (; left && vleft--; i++, first=0) {
		if (write) {
			while (left) {
				char c;
Start --->
				if (get_user(c,(char __user *) buffer))
					return -EFAULT;
Error --->
				if (!isspace(c))
					break;
				left--;
				buffer++;

---------------------------------------------------------
[BUG]
/home/kash/linux/linux-2.6.5/lib/bitmap.c:238:bitmap_parse: ERROR:TAINT:
235:238:Using user value "c" without first performing bounds checks
[SOURCE_MODEL=(lib,get_user,user,taint)] [PATH=]

		chunk = ndigits = 0;

		/* Get the next chunk of the bitmap */
		while (ubuflen) {
			old_c = c;
Start --->
			if (get_user(c, ubuf++))
				return -EFAULT;
			ubuflen--;
Error --->
			if (isspace(c))
				continue;

			/*


             reply	other threads:[~2004-04-20 23:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-20 22:14 ken [this message]
2004-04-20 23:25 ` viro
2004-04-20 23:57   ` ken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12837.24.6.86.122.1082499261.spork@webmail.coverity.com \
    --to=ken@coverity.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@coverity.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®