From patchwork Tue Sep 29 23:10:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Cameron X-Patchwork-Id: 7291361 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 051339F39B for ; Tue, 29 Sep 2015 23:11:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27FFA2066D for ; Tue, 29 Sep 2015 23:11:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E66582066B for ; Tue, 29 Sep 2015 23:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751255AbbI2XLD (ORCPT ); Tue, 29 Sep 2015 19:11:03 -0400 Received: from zimbra.real-time.com ([63.170.91.9]:37203 "EHLO zimbra.real-time.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810AbbI2XLB (ORCPT ); Tue, 29 Sep 2015 19:11:01 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.real-time.com (Postfix) with ESMTP id 66DC448508E; Tue, 29 Sep 2015 18:10:59 -0500 (CDT) X-Virus-Scanned: amavisd-new at mn.real-time.com Received: from zimbra.real-time.com ([127.0.0.1]) by localhost (zimbra.real-time.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pm6KLfO-cnQx; Tue, 29 Sep 2015 18:10:58 -0500 (CDT) Received: from esk.lan (pa122-110-90-76.pa.nsw.optusnet.com.au [122.110.90.76]) by zimbra.real-time.com (Postfix) with ESMTPSA id CBD5C484DD6; Tue, 29 Sep 2015 18:10:57 -0500 (CDT) Received: from james by esk.lan with local (Exim 4.82) (envelope-from ) id 1Zh42g-0004lr-JN; Wed, 30 Sep 2015 09:10:38 +1000 Date: Wed, 30 Sep 2015 09:10:38 +1000 From: James Cameron To: PaX Team Cc: Amitkumar Karwar , Avinash Patil , Kalle Valo , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, re.emese@gmail.com, spender@grsecurity.net Subject: Re: question about potential integer truncation in mwifiex_set_wapi_ie and mwifiex_set_wps_ie Message-ID: <20150929231038.GG8613@us.netrek.org> References: <560AAC78.14106.6193CAA9@pageexec.freemail.hu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <560AAC78.14106.6193CAA9@pageexec.freemail.hu> Organization: Netrek Vanilla Server Dictator User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Sep 29, 2015 at 05:21:28PM +0200, PaX Team wrote: > hi all, > > in drivers/net/wireless/mwifiex/sta_ioctl.c the following functions > > mwifiex_set_wpa_ie_helper > mwifiex_set_wapi_ie > mwifiex_set_wps_ie > > can truncate the incoming ie_len argument from u16 to u8 when it gets > stored in mwifiex_private.wpa_ie_len, mwifiex_private.wapi_ie_len and > mwifiex_private.wps_ie_len, respectively. based on some light code > reading it seems a length value of 256 is valid (IEEE_MAX_IE_SIZE and > MWIFIEX_MAX_VSIE_LEN seem to limit it) and thus would get truncated > to 0 when stored in those u8 fields. the question is whether this is > intentional or a bug somewhere. i agree, while there is a test to ensure ie_len is not greater than 256, there is a possibility that it will be exactly 256, which means 256 bytes will be given to memcpy but mwifiex_private.{wpa,wapi,wps}_ie_len will be zero. i suggest changing the lengths to u16. not tested. diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index fe12560..b66e9a7 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -512,14 +512,14 @@ struct mwifiex_private { struct mwifiex_wep_key wep_key[NUM_WEP_KEYS]; u16 wep_key_curr_index; u8 wpa_ie[256]; - u8 wpa_ie_len; + u16 wpa_ie_len; u8 wpa_is_gtk_set; struct host_cmd_ds_802_11_key_material aes_key; struct host_cmd_ds_802_11_key_material_v2 aes_key_v2; u8 wapi_ie[256]; - u8 wapi_ie_len; + u16 wapi_ie_len; u8 *wps_ie; - u8 wps_ie_len; + u16 wps_ie_len; u8 wmm_required; u8 wmm_enabled; u8 wmm_qosinfo;