From: Chris Wright <chrisw@osdl.org>
To: Ken Ashcraft <ken@coverity.com>
Cc: linux-kernel@vger.kernel.org, mc@cs.stanford.edu, coreteam@netfilter.org
Subject: Re: [CHECKER] Probable security holes in 2.6.5
Date: Fri, 16 Apr 2004 12:19:55 -0700 [thread overview]
Message-ID: <20040416121955.Y22989@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] overflow in SMP_ALIGN?
> /home/kash/linux/linux-2.6.5/net/ipv6/netfilter/ip6_tables.c:1156:do_replace: ERROR:TAINT: 1144:1156:Passing unbounded user value "(tmp).size" as arg 2 to function "copy_from_user", which uses it unsafely in model [SOURCE_MODEL=(lib,copy_from_user,user,taintscalar)] [SINK_MODEL=(lib,copy_from_user,user,trustingsink)] [PATH=]
> struct ip6t_replace tmp;
> struct ip6t_table *t;
> struct ip6t_table_info *newinfo, *oldinfo;
> struct ip6t_counters *counters;
>
> Start --->
> if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
> return -EFAULT;
>
> /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */
> if ((SMP_ALIGN(tmp.size) >> PAGE_SHIFT) + 2 > num_physpages)
> return -ENOMEM;
>
> newinfo = vmalloc(sizeof(struct ip6t_table_info)
> + SMP_ALIGN(tmp.size) * NR_CPUS);
> if (!newinfo)
> return -ENOMEM;
>
> Error --->
> if (copy_from_user(newinfo->entries, user + sizeof(tmp),
> tmp.size) != 0) {
> ret = -EFAULT;
> goto free_newinfo;
I don't think there's an overflow here. Just possiblity of large
allocations. Seems sane to me to have some limits. Also nothing
seems to sanity check against the tmp.num_counters sized vmalloc().
I do believe these are protected by capable() check.
> ---------------------------------------------------------
> [BUG] overflow in SMP_ALIGN?
> /home/kash/linux/linux-2.6.5/net/ipv4/netfilter/arp_tables.c:891:do_replace: ERROR:TAINT: 875:891:Passing unbounded user value "(tmp).size" as arg 2 to function "copy_from_user", which uses it unsafely in model [SOURCE_MODEL=(lib,copy_from_user,user,taintscalar)] [SINK_MODEL=(lib,copy_from_user,user,trustingsink)] [PATH=]
> struct arpt_replace tmp;
> struct arpt_table *t;
> struct arpt_table_info *newinfo, *oldinfo;
> struct arpt_counters *counters;
>
> Start --->
> if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
>
> ... DELETED 10 lines ...
>
> newinfo = vmalloc(sizeof(struct arpt_table_info)
> + SMP_ALIGN(tmp.size) * NR_CPUS);
> if (!newinfo)
> return -ENOMEM;
>
> Error --->
> if (copy_from_user(newinfo->entries, user + sizeof(tmp),
> tmp.size) != 0) {
> ret = -EFAULT;
> goto free_newinfo;
There's a couple checks here:
/* Hack: Causes ipchains to give correct error msg --RR */
if (len != sizeof(tmp) + tmp.size)
return -ENOPROTOOPT;
/* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */
if ((SMP_ALIGN(tmp.size) >> PAGE_SHIFT) + 2 > num_physpages)
return -ENOMEM;
Are these sufficient to limit considering the allocation is sized by
'SMP_ALIGN(tmp.size) * NR_CPUS'? And nothing checking tmp.num_counters.
Again, protected by capable().
> ---------------------------------------------------------
> [BUG] overflow in SMP_ALIGN?
> /home/kash/linux/linux-2.6.5/net/ipv4/netfilter/ip_tables.c:1074:do_replace: ERROR:TAINT: 1058:1074:Passing unbounded user value "(tmp).size" as arg 2 to function "copy_from_user", which uses it unsafely in model [SOURCE_MODEL=(lib,copy_from_user,user,taintscalar)] [SINK_MODEL=(lib,copy_from_user,user,trustingsink)] [PATH=]
> struct ipt_replace tmp;
> struct ipt_table *t;
> struct ipt_table_info *newinfo, *oldinfo;
> struct ipt_counters *counters;
>
> Start --->
> if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
>
> ... DELETED 10 lines ...
>
> newinfo = vmalloc(sizeof(struct ipt_table_info)
> + SMP_ALIGN(tmp.size) * NR_CPUS);
> if (!newinfo)
> return -ENOMEM;
>
> Error --->
> if (copy_from_user(newinfo->entries, user + sizeof(tmp),
> tmp.size) != 0) {
> ret = -EFAULT;
> goto free_newinfo;
same here.
thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
next prev parent reply other threads:[~2004-04-16 19:20 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
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 [this message]
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=20040416121955.Y22989@build.pdx.osdl.net \
--to=chrisw@osdl.org \
--cc=coreteam@netfilter.org \
--cc=ken@coverity.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mc@cs.stanford.edu \
/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®