mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean Tourrilhes <jt@hpl.hp.com>
To: Kees Cook <kees.cook@canonical.com>
Cc: linux-kernel@vger.kernel.org,
	"John W. Linville" <linville@tuxdriver.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	Joe Perches <joe@perches.com>, Tejun Heo <tj@kernel.org>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] wireless: fix 64K kernel heap content leak via ioctl
Date: Fri, 27 Aug 2010 14:22:54 -0700	[thread overview]
Message-ID: <20100827212254.GB32275@bougret.hpl.hp.com> (raw)
In-Reply-To: <20100827210240.GC4703@outflux.net>

On Fri, Aug 27, 2010 at 02:02:41PM -0700, Kees Cook wrote:
> This problem was originally tracked down by Brad Spengler.
> 
> When calling wireless ioctls, if a driver does not correctly
> validate/shrink iwp->length, the resulting copy_to_user can leak up to
> 64K of kernel heap contents.
> 
> It seems that this is triggerable[1] in 2.6.32 at least on ath5k, but
> I was not able to track down how. The twisty maze of ioctl handlers
> stumped me. :)

	You can always ask.

> Other drivers I checked did not appear to have any problems,
> but the potential remains. I'm not sure if this patch is the right approach;
> it was fixed differently[2] in grsecurity.

	Did you tried your patch for real ? With large scan request ?
	I ask because at first glance, it looks incorrect, asI believe
it kills large request. But someone would need to test, for sure.

> [1] http://forums.grsecurity.net/viewtopic.php?f=3&t=2290&start=0
> [2] http://grsecurity.net/~spender/wireless-infoleak-fix2.patch

	I believe this patch would make the situation worse.

	Would you mind validating the following patch ? I've just
verified that it compiles and I believe it does what you are asking in
a much more predictable way.
	Regards,

	Jean

Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com>

diff -u -p wext.j2.c wext.c
--- wext.j2.c   2010-08-27 14:17:26.000000000 -0700
+++ wext.c      2010-08-27 14:19:33.000000000 -0700
@@ -800,9 +800,12 @@ static int ioctl_standard_iw_point(struc
                        goto out;
                }
 
-               if (copy_to_user(iwp->pointer, extra,
-                                iwp->length *
-                                descr->token_size)) {
+               /* Verify how much we should return. Some driver
+                * may abuse iwp->length... */
+               if((iwp->length * descr->token_size) < extra_size)
+                       extra_size = iwp->length * descr->token_size;
+
+               if (copy_to_user(iwp->pointer, extra, extra_size)) {
                        err = -EFAULT;
                        goto out;
                }

  reply	other threads:[~2010-08-27 21:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-27 21:02 Kees Cook
2010-08-27 21:22 ` Jean Tourrilhes [this message]
2010-08-27 21:43   ` Kees Cook
2010-08-27 21:53     ` Jean Tourrilhes
2010-08-27 22:35   ` Luis R. Rodriguez
2010-08-27 22:39     ` Jean Tourrilhes
2010-08-27 22:51       ` Luis R. Rodriguez
2010-08-30  8:47   ` Johannes Berg
2010-08-30  8:58     ` Johannes Berg
2010-08-30  9:59       ` Johannes Berg
2010-08-30 10:24         ` [PATCH] wireless extensions: fix kernel heap content leak Johannes Berg
2010-08-30 18:03           ` Kees Cook
2010-08-30 18:06             ` Johannes Berg
2010-08-30 17:40         ` [PATCH] wireless: fix 64K kernel heap content leak via ioctl Jean Tourrilhes
2010-08-30 17:50           ` Johannes Berg
2010-09-15 22:48 ` [vendor-sec] " Greg KH
2010-09-15 23:11   ` Johannes Berg
2010-09-15 23:28     ` Greg KH

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=20100827212254.GB32275@bougret.hpl.hp.com \
    --to=jt@hpl.hp.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=joe@perches.com \
    --cc=johannes@sipsolutions.net \
    --cc=kees.cook@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=tj@kernel.org \
    /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®