From root@kjell.utb.falun.se  Fri Jun 28 13:25:37 2002
Return-Path: <root@kjell.utb.falun.se>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A4AF737B400
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 28 Jun 2002 13:25:36 -0700 (PDT)
Received: from kjell.utb.falun.se (gw2.falun.se [192.121.234.252])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E27E343E06
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 28 Jun 2002 13:25:35 -0700 (PDT)
	(envelope-from root@kjell.utb.falun.se)
Received: by kjell.utb.falun.se (Postfix, from userid 0)
	id 82DCA2D1; Fri, 28 Jun 2002 22:26:06 +0200 (CEST)
Message-Id: <20020628202606.82DCA2D1@kjell.utb.falun.se>
Date: Fri, 28 Jun 2002 22:26:06 +0200 (CEST)
From: elias@kjell.utb.falun.se
Reply-To: elias@kjell.utb.falun.se
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: wi driver can cause system crash when trying to handle negative value for WI_RID_TX_CRYPT_KEY
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         39960
>Category:       kern
>Synopsis:       wi driver can cause system crash when trying to handle negative value for WI_RID_TX_CRYPT_KEY
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 28 13:30:01 PDT 2002
>Closed-Date:    Sun Sep 29 12:42:05 MDT 2002
>Last-Modified:  Sun Sep 29 12:42:05 MDT 2002
>Originator:     Elias Norberg
>Release:        FreeBSD 4.6-RELEASE i386
>Organization:
>Environment:
System: FreeBSD node23 4.6-RELEASE FreeBSD 4.6-RELEASE #1: Sat Jun 22 16:22:28 CEST 2002 root@node23:/usr/src/sys/compile/FreeBSD i386

>Description:
	
	When executing the following command on a computer with
	the 3CRWE777A wireless device, the system crashes:
	
	wicontrol -T 0 

	In turn, wicontol executes the following code:
	(this code has been shortened down to show the
	 cause of the problem)
	----------
	struct wi_req wreq;
	struct ifreq ifr;
	int sock;

	sock = socket(AF_INET, SOCK_DGRAM, 0);
	wreq.wi_type = WI_RID_TX_CRYPT_KEY;
	wreq.wi_len = 2;
	wreq.wi_val[0] = -1;

	bzero(&ifr, sizeof(ifr));
	strcpy(ifr.ifr_name, "wi0");
	ifr.ifr_data = (caddr_t)&wreq;

	ioctl(sock, SIOCSWAVELAN, &ifr )

	close(sock);
	----------

	When this ioctl is executed, the system crashes, due
	to an illegal value being written to the wireless card.
	 
>How-To-Repeat:
	
	
	See above for a complete code-snippet which reproduces this,
	alternatively, try executing 'wicontrol -T 0'.
	
>Fix:
	
	Below is a patch for sys/dev/wi/if_wi.c from 4.6-RELEASE.
	This takes care of the problem, and shouldnt break anything,
	since the standard values range from 0 to 3.

	
>Release-Note:
>Audit-Trail:

From: elias@kjell.utb.falun.se (elias)
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/39960: wi driver can cause system crash when trying to handle negative value for WI_RID_TX_CRYPT_KEY
Date: Fri, 28 Jun 2002 23:01:18 +0200 (CEST)

 Here's the patch. (somehow it was left out of the original post)
 
 ----cut------------
 *** if_wi.c.old Fri Jun 28 15:42:24 2002
 --- if_wi.c     Fri Jun 28 15:45:20 2002
 ***************
 *** 1151,1156 ****
 --- 1151,1159 ----
                         ltv = &p2ltv;
                         break;
                 case WI_RID_TX_CRYPT_KEY:
 +                       /* negative can values result in kernel crash */
 +                       if( ltv->wi_val < 0 )
 +                               return 0;
                         p2ltv.wi_type = WI_RID_P2_TX_CRYPT_KEY;
                         p2ltv.wi_len = 2;
                         p2ltv.wi_val = ltv->wi_val;
 ----cut------------
Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: johan 
Responsible-Changed-When: Mon Jul 22 20:50:36 PDT 2002 
Responsible-Changed-Why:  
Over to if_wi maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=39960 
State-Changed-From-To: open->closed 
State-Changed-By: imp 
State-Changed-When: Sun Sep 29 12:41:49 MDT 2002 
State-Changed-Why:  
Fixed 


http://www.freebsd.org/cgi/query-pr.cgi?pr=39960 
>Unformatted:
