From patchwork Sun Feb 9 16:58:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 11372197 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E4CD186E for ; Sun, 9 Feb 2020 16:59:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEFB920726 for ; Sun, 9 Feb 2020 16:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727883AbgBIQ7S (ORCPT ); Sun, 9 Feb 2020 11:59:18 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49163 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727723AbgBIQ7P (ORCPT ); Sun, 9 Feb 2020 11:59:15 -0500 Received: from isengard.fritz.box (unknown [84.174.247.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id E4A4C580068; Sun, 9 Feb 2020 17:59:12 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 1/8] iw: scan: parse measurement pilot element Date: Sun, 9 Feb 2020 17:58:55 +0100 Message-Id: <20200209165902.44110-2-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> References: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Markus Theil --- scan.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/scan.c b/scan.c index 50a4147..a6cb3bb 100644 --- a/scan.c +++ b/scan.c @@ -1530,6 +1530,47 @@ static void print_supp_op_classes(const uint8_t type, uint8_t len, } } +static void print_measurement_pilot_tx(const uint8_t type, uint8_t len, + const uint8_t *data, + const struct print_ies_data *ie_buffer) +{ + printf("\n"); + printf("\t\t * interval: %d TUs\n", data[0]); + + if(len <= 1) + return; + + uint8_t *p = (uint8_t *) data + 1; + uint8_t len_remaining = len - 1; + + while (len_remaining >=5) { + uint8_t subelement_id = *p; + ++p; + uint8_t len = *p; + ++p; + + len_remaining -= 2; + + /* 802.11-2016 only allows vendor specific elements */ + if (subelement_id != 221) { + printf("\t\t * \n", subelement_id); + return; + } + + printf("\t\t * vendor specific: OUI %.2x:%.2x:%.2x, data:", + p[0], p[1], p[2]); + len_remaining -= 3; + + if (len > len_remaining) + printf(" \n"); + return; + + while (p < p + len) + printf(" %.2x", *p); + printf("\n"); + } +} + static void print_obss_scan_params(const uint8_t type, uint8_t len, const uint8_t *data, const struct print_ies_data *ie_buffer) @@ -1652,6 +1693,7 @@ static const struct ie_print ieprinters[] = { [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), }, [47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), }, [59] = { "Supported operating classes", print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), }, + [66] = { "Measurement Pilot Transmission", print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), }, [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), }, [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), }, [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), }, From patchwork Sun Feb 9 16:58:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 11372191 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9400617EF for ; Sun, 9 Feb 2020 16:59:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D4D020726 for ; Sun, 9 Feb 2020 16:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgBIQ7P (ORCPT ); Sun, 9 Feb 2020 11:59:15 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49166 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727698AbgBIQ7P (ORCPT ); Sun, 9 Feb 2020 11:59:15 -0500 Received: from isengard.fritz.box (unknown [84.174.247.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id 347B558006E; Sun, 9 Feb 2020 17:59:13 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 2/8] iw: scan: fix buffer over-read in print_ies() Date: Sun, 9 Feb 2020 17:58:56 +0100 Message-Id: <20200209165902.44110-3-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> References: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This patch correctly checks, if enough data bytes for parsing IEs are present (-2 in check for type and length). Furthermore, it adds a nullptr and length check to ease future fuzzing. Signed-off-by: Markus Theil --- scan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scan.c b/scan.c index a6cb3bb..14138ca 100644 --- a/scan.c +++ b/scan.c @@ -2181,7 +2181,10 @@ void print_ies(unsigned char *ie, int ielen, bool unknown, .ie = ie, .ielen = ielen }; - while (ielen >= 2 && ielen >= ie[1]) { + if (ie == NULL || ielen < 0) + return; + + while (ielen >= 2 && ielen - 2 >= ie[1]) { if (ie[0] < ARRAY_SIZE(ieprinters) && ieprinters[ie[0]].name && ieprinters[ie[0]].flags & BIT(ptype)) { From patchwork Sun Feb 9 16:58:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 11372187 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABB7917EF for ; Sun, 9 Feb 2020 16:59:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9456120820 for ; Sun, 9 Feb 2020 16:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727855AbgBIQ7Q (ORCPT ); Sun, 9 Feb 2020 11:59:16 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49172 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbgBIQ7P (ORCPT ); Sun, 9 Feb 2020 11:59:15 -0500 Received: from isengard.fritz.box (unknown [84.174.247.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id BB199580074; Sun, 9 Feb 2020 17:59:13 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 4/8] iw: scan: fix buffer over-read in parsing roaming consortium Date: Sun, 9 Feb 2020 17:58:58 +0100 Message-Id: <20200209165902.44110-5-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> References: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org ANQP and OI length are always present, increase min. length by 2. Signed-off-by: Markus Theil --- scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan.c b/scan.c index 2d11f81..9a02363 100644 --- a/scan.c +++ b/scan.c @@ -1707,7 +1707,7 @@ static const struct ie_print ieprinters[] = { [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), }, [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), }, [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), }, - [111] = { "802.11u Roaming Consortium", print_11u_rcon, 0, 255, BIT(PRINT_SCAN), }, + [111] = { "802.11u Roaming Consortium", print_11u_rcon, 2, 255, BIT(PRINT_SCAN), }, [195] = { "Transmit Power Envelope", print_tx_power_envelope, 2, 5, BIT(PRINT_SCAN), }, }; From patchwork Sun Feb 9 16:58:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 11372193 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B43F6109A for ; Sun, 9 Feb 2020 16:59:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DE0A20726 for ; Sun, 9 Feb 2020 16:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727877AbgBIQ7S (ORCPT ); Sun, 9 Feb 2020 11:59:18 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49180 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727850AbgBIQ7R (ORCPT ); Sun, 9 Feb 2020 11:59:17 -0500 Received: from isengard.fritz.box (unknown [84.174.247.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id 09B94580075; Sun, 9 Feb 2020 17:59:14 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 5/8] iw: scan: fix buffer over-read in print_wifi_wps Date: Sun, 9 Feb 2020 17:58:59 +0100 Message-Id: <20200209165902.44110-6-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> References: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Markus Theil --- scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan.c b/scan.c index 9a02363..f57925d 100644 --- a/scan.c +++ b/scan.c @@ -1818,7 +1818,7 @@ static void print_wifi_wps(const uint8_t type, uint8_t len, const uint8_t *data, while (len >= 4) { subtype = (data[0] << 8) + data[1]; sublen = (data[2] << 8) + data[3]; - if (sublen > len) + if (sublen > len - 4) break; switch (subtype) { From patchwork Sun Feb 9 16:59:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 11372195 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D54F918B8 for ; Sun, 9 Feb 2020 16:59:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE7E920726 for ; Sun, 9 Feb 2020 16:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727879AbgBIQ7S (ORCPT ); Sun, 9 Feb 2020 11:59:18 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49181 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbgBIQ7R (ORCPT ); Sun, 9 Feb 2020 11:59:17 -0500 Received: from isengard.fritz.box (unknown [84.174.247.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id 558B7580076; Sun, 9 Feb 2020 17:59:14 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 6/8] iw: scan: fix buffer over-read in print_p2p Date: Sun, 9 Feb 2020 17:59:00 +0100 Message-Id: <20200209165902.44110-7-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> References: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Markus Theil --- scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scan.c b/scan.c index f57925d..b3e7baa 100644 --- a/scan.c +++ b/scan.c @@ -2036,7 +2036,7 @@ static inline void print_p2p(const uint8_t type, uint8_t len, case 0x12: /* invitation flags */ case 0xdd: /* vendor specific */ default: { - const __u8 *subdata = data + 4; + const __u8 *subdata = data + 3; __u16 tmplen = sublen; tab_on_first(&first); From patchwork Sun Feb 9 16:59:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 11372199 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B6FE1922 for ; Sun, 9 Feb 2020 16:59:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14BA920726 for ; Sun, 9 Feb 2020 16:59:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbgBIQ7R (ORCPT ); Sun, 9 Feb 2020 11:59:17 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49182 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbgBIQ7R (ORCPT ); Sun, 9 Feb 2020 11:59:17 -0500 Received: from isengard.fritz.box (unknown [84.174.247.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id A0847580078; Sun, 9 Feb 2020 17:59:14 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 7/8] iw: scan: fix undefined behaviour in rm capa print Date: Sun, 9 Feb 2020 17:59:01 +0100 Message-Id: <20200209165902.44110-8-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> References: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Markus Theil --- scan.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scan.c b/scan.c index b3e7baa..e2a620a 100644 --- a/scan.c +++ b/scan.c @@ -586,10 +586,10 @@ static void print_rm_enabled_capabilities(const uint8_t type, uint8_t len, const uint8_t *data, const struct print_ies_data *ie_buffer) { - __u64 capa = data[0] | - data[1] << 8 | - data[2] << 16 | - data[3] << 24 | + __u64 capa = ((__u64) data[0]) | + ((__u64) data[1]) << 8 | + ((__u64) data[2]) << 16 | + ((__u64) data[3]) << 24 | ((__u64) data[4]) << 32; printf("\n"); From patchwork Sun Feb 9 16:59:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 11372201 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADF1914D5 for ; Sun, 9 Feb 2020 16:59:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96B6720733 for ; Sun, 9 Feb 2020 16:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727870AbgBIQ7R (ORCPT ); Sun, 9 Feb 2020 11:59:17 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49183 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbgBIQ7R (ORCPT ); Sun, 9 Feb 2020 11:59:17 -0500 Received: from isengard.fritz.box (unknown [84.174.247.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id E2A6858007B; Sun, 9 Feb 2020 17:59:14 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 8/8] iw: scan: fix undefined behaviour in print_vht_capa() Date: Sun, 9 Feb 2020 17:59:02 +0100 Message-Id: <20200209165902.44110-9-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> References: <20200209165902.44110-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Markus Theil --- scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan.c b/scan.c index e2a620a..8f8d8ba 100644 --- a/scan.c +++ b/scan.c @@ -1473,8 +1473,8 @@ static void print_vht_capa(const uint8_t type, uint8_t len, const uint8_t *data, const struct print_ies_data *ie_buffer) { printf("\n"); - print_vht_info(data[0] | (data[1] << 8) | - (data[2] << 16) | (data[3] << 24), + print_vht_info((__u32) data[0] | ((__u32)data[1] << 8) | + ((__u32)data[2] << 16) | ((__u32)data[3] << 24), data + 4); }