mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: Ken Ashcraft <ken@coverity.com>
Cc: linux-kernel@vger.kernel.org, mc@cs.stanford.edu,
	scott.feldman@intel.com, jgarzik@pobox.com
Subject: Re: [CHECKER] Probable security holes in 2.6.5
Date: Fri, 16 Apr 2004 11:20:51 -0700	[thread overview]
Message-ID: <20040416112051.V22989@build.pdx.osdl.net> (raw)
In-Reply-To: <1082134916.19301.7.camel@dns.coverity.int>; from ken@coverity.com on Fri, Apr 16, 2004 at 10:01:57AM -0700

* Ken Ashcraft (ken@coverity.com) wrote:
> [BUG]
> /home/kash/linux/linux-2.6.5/drivers/net/e1000/e1000_ethtool.c:1494:e1000_ethtool_ioctl: ERROR:TAINT: 1487:1494:Passing unbounded user value "(regs).len" as arg 2 to function "copy_to_user", which uses it unsafely in model [SOURCE_MODEL=(lib,copy_from_user,user,taintscalar)] [SINK_MODEL=(lib,copy_to_user,user,trustingsink)]    [PATH=] 
> 	}
> 	case ETHTOOL_GREGS: {
> 		struct ethtool_regs regs = {ETHTOOL_GREGS};
> 		uint32_t regs_buff[E1000_REGS_LEN];
> 
> Start --->
> 		if(copy_from_user(&regs, addr, sizeof(regs)))
> 			return -EFAULT;
> 		e1000_ethtool_gregs(adapter, &regs, regs_buff);
> 		if(copy_to_user(addr, &regs, sizeof(regs)))
> 			return -EFAULT;
> 
> 		addr += offsetof(struct ethtool_regs, data);
> Error --->
> 		if(copy_to_user(addr, regs_buff, regs.len))
> 			return -EFAULT;
> 
> 		return 0;

Looks like a bug.  Possible patch below zeros the buffer (since it's not
filled completely by e1000_ethtool_gregs()), and truncates len.

thanks,
-chris
-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net

===== drivers/net/e1000/e1000_ethtool.c 1.42 vs edited =====
--- 1.42/drivers/net/e1000/e1000_ethtool.c	Fri Apr  9 16:39:34 2004
+++ edited/drivers/net/e1000/e1000_ethtool.c	Fri Apr 16 11:20:03 2004
@@ -1514,6 +1514,9 @@
 
 		if(copy_from_user(&regs, addr, sizeof(regs)))
 			return -EFAULT;
+		memset(regs_buff, 0, sizeof(regs_buff));
+		if (regs.len > E1000_REGS_LEN)
+			regs.len = E1000_REGS_LEN;
 		e1000_ethtool_gregs(adapter, &regs, regs_buff);
 		if(copy_to_user(addr, &regs, sizeof(regs)))
 			return -EFAULT;

  reply	other threads:[~2004-04-16 18:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-16 17:01 Ken Ashcraft
2004-04-16 18:20 ` Chris Wright [this message]
2004-04-16 19:20   ` Jeff Garzik
2004-04-16 22:12     ` Chris Wright
2004-04-19 16:46   ` Jeff Garzik
2004-04-16 18:32 ` Chris Wright
2004-04-16 18:54 ` Chris Wright
2004-04-21  1:34   ` Andrea Arcangeli
2004-04-21  1:38     ` Chris Wright
2004-04-16 19:19 ` Chris Wright
2004-04-16 19:27 ` Chris Wright
2004-04-17  6:15   ` Rusty Russell
2004-04-16 20:02 ` Chris Wright
2004-04-16 20:23 ` Chris Wright
2004-04-17  0:16 ` Chris Wright
2004-04-17  1:00 ` Chris Wright
2004-04-19 16:27   ` Jeff Garzik
2004-04-19 19:09 ` Chris Wright
2004-04-19 20:38 ` Chris Wright

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=20040416112051.V22989@build.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=ken@coverity.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mc@cs.stanford.edu \
    --cc=scott.feldman@intel.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®