Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1903648ybl; Tue, 3 Dec 2019 14:44:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwaEa7HWHDKlUvSgBPeOuiV2GXy48Z0qNJbjtx3Cz9hBYB4vx/tCOHkc6NVwk8bwVe3+EzB X-Received: by 2002:a05:6830:1e81:: with SMTP id n1mr189316otr.53.1575413044909; Tue, 03 Dec 2019 14:44:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575413044; cv=none; d=google.com; s=arc-20160816; b=RbaZqWf3juIpCgokPJ7AofG9yH/AF3Qbv3cyoyawLpShA66TzEQJ3EAqpl5wbYOGqq ARjS4pEJVk+b9CUbIi5d9Qn4YVKiMGdKayOBqLS7v2ZxLPGDhKLOt6qKswBchp89J4vy sqGFb/54PXIs3pEq81b1yU/kQq15eq3XpB3li2LPZ78unEw/q4HLAl+rTeU1RxRokILG mAyEmabVfHzGGFveA28d0xUiOx+T7CvKXaW+NuLXhU/ihXTWe6zp4OrwIyHaqmF1Ic5M q6knBtwfzXH9ZuxciaORr8UGGfmI1k5AIyb7FbPLx7FTMo0dS9jbf6yvoEZzACmZeOGa voTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XOu/WRQLc6w8EmI8JQYLKxTthqLBxhBTiyr9LqH2aag=; b=fJ7AE84TGC8vjcKOTQHKf2WRXjajdxQUP5TD84DlfQceSYreB7XuDg4FFANgiS4KBv d81bzZMk7iOx2pvEw7+ef9qoPznxBC5rDyxhmIhy2b6n/Jre50+Ma8ShUxoR8L3zZDQB D8hRCFo9/s5tduqsTc36zeoCW6H+Tttm2QaSIMfUYwAVEM6nS2gfBqRlAfWYhKlERFC1 AgTyKZibhtOVGdVrLAG/OtTX5DtondFSIT9R5admGdAOBqSNGiotMPdDswxSvR7IrlLT rtdOOwbN3uAn+6xhZFRbD3GuBtaisIM9SzuSlzLUODNUSVYHt+FCqv3JMj927HUcNtKR UJ4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yQEPpgHb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si2235229otq.321.2019.12.03.14.43.53; Tue, 03 Dec 2019 14:44:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yQEPpgHb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbfLCWn0 (ORCPT + 99 others); Tue, 3 Dec 2019 17:43:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:58774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728475AbfLCWnY (ORCPT ); Tue, 3 Dec 2019 17:43:24 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9DADF20803; Tue, 3 Dec 2019 22:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575413002; bh=fTap50hOM9PnZz9jwJ7d7gNLsTKF+xqDJGkeYz8Vz6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yQEPpgHb5znYilXwouZqxqIcIY5w4b4OBusJU0MUvqpKbK6YMXxzcSEqnOyAxpFi9 6x/3d+FmIZA+S6XeNiw4xCZ7JlSp5Xn26yq4esU5oZYpGeYPHpJ+7djLWo/QT8x0kW f671tUlEzXxYqYBdOEUue/NDQx9V4EME2H+6/EbI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, coverity-bot , Ajay Singh Subject: [PATCH 5.3 099/135] staging: wilc1000: fix illegal memory access in wilc_parse_join_bss_param() Date: Tue, 3 Dec 2019 23:35:39 +0100 Message-Id: <20191203213039.028949888@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203213005.828543156@linuxfoundation.org> References: <20191203213005.828543156@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ajay Singh commit c7e621bb981b76d3bfd8a595070ee8282ac4a32b upstream. Do not copy the extended supported rates in 'param->supp_rates' if the array is already full with basic rates values. The array size check helped to avoid possible illegal memory access [1] while copying to 'param->supp_rates' array. 1. https://marc.info/?l=linux-next&m=157301720517456&w=2 Reported-by: coverity-bot Addresses-Coverity-ID: 1487400 ("Memory - illegal accesses") Fixes: 4e0b0f42c9c7 ("staging: wilc1000: use struct to pack join parameters for FW") Cc: stable@vger.kernel.org Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191106062127.3165-1-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_hif.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- a/drivers/staging/wilc1000/wilc_hif.c +++ b/drivers/staging/wilc1000/wilc_hif.c @@ -477,16 +477,21 @@ void *wilc_parse_join_bss_param(struct c memcpy(¶m->supp_rates[1], rates_ie + 2, rates_len); } - supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, ies->data, - ies->len); - if (supp_rates_ie) { - if (supp_rates_ie[1] > (WILC_MAX_RATES_SUPPORTED - rates_len)) - param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED; - else - param->supp_rates[0] += supp_rates_ie[1]; + if (rates_len < WILC_MAX_RATES_SUPPORTED) { + supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, + ies->data, ies->len); + if (supp_rates_ie) { + u8 ext_rates = supp_rates_ie[1]; - memcpy(¶m->supp_rates[rates_len + 1], supp_rates_ie + 2, - (param->supp_rates[0] - rates_len)); + if (ext_rates > (WILC_MAX_RATES_SUPPORTED - rates_len)) + param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED; + else + param->supp_rates[0] += ext_rates; + + memcpy(¶m->supp_rates[rates_len + 1], + supp_rates_ie + 2, + (param->supp_rates[0] - rates_len)); + } } ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len);