Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753253Ab0H0V3I (ORCPT ); Fri, 27 Aug 2010 17:29:08 -0400 Received: from madara.hpl.hp.com ([192.6.19.124]:52517 "EHLO madara.hpl.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169Ab0H0V3F (ORCPT ); Fri, 27 Aug 2010 17:29:05 -0400 X-Greylist: delayed 310 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Aug 2010 17:29:05 EDT Date: Fri, 27 Aug 2010 14:22:54 -0700 From: Jean Tourrilhes To: Kees Cook Cc: linux-kernel@vger.kernel.org, "John W. Linville" , "David S. Miller" , Eric Dumazet , Johannes Berg , Joe Perches , Tejun Heo , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH] wireless: fix 64K kernel heap content leak via ioctl Message-ID: <20100827212254.GB32275@bougret.hpl.hp.com> Reply-To: jt@hpl.hp.com References: <20100827210240.GC4703@outflux.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100827210240.GC4703@outflux.net> Organisation: HP Labs Palo Alto Address: HP Labs, 1U-17, 1501 Page Mill road, Palo Alto, CA 94304, USA. E-mail: jt@hpl.hp.com User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2332 Lines: 59 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 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; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/