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: 216497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B086C352A4 for ; Sun, 9 Feb 2020 16:59:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D865F20726 for ; Sun, 9 Feb 2020 16:59:21 +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: 216500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7F0CC352A4 for ; Sun, 9 Feb 2020 16:59:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9940C20726 for ; Sun, 9 Feb 2020 16:59:18 +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:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 216501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EAC4C35250 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 72ECF20733 for ; Sun, 9 Feb 2020 16:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727848AbgBIQ7P (ORCPT ); Sun, 9 Feb 2020 11:59:15 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:49169 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727753AbgBIQ7P (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 77DFE580073; 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 3/8] iw: scan: fix buffer over-read in operation class parsing Date: Sun, 9 Feb 2020 17:58:57 +0100 Message-Id: <20200209165902.44110-4-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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scan.c b/scan.c index 14138ca..2d11f81 100644 --- a/scan.c +++ b/scan.c @@ -1507,7 +1507,7 @@ static void print_supp_op_classes(const uint8_t type, uint8_t len, printf("\n"); printf("\t\t * current operating class: %d\n", *p); - while (p++ < next_data) { + while (++p < next_data) { if (*p == 130) { one_hundred_thirty_delimiter = 1; break; @@ -1519,11 +1519,11 @@ static void print_supp_op_classes(const uint8_t type, uint8_t len, printf("\t\t * operating class: %d\n", *p); } if (one_hundred_thirty_delimiter) - while (p++ < next_data) { + while (++p < next_data) { printf("\t\t * current operating class extension: %d\n", *p); } if (zero_delimiter) - while (p++ < next_data - 1) { + while (++p < next_data - 1) { printf("\t\t * operating class duple: %d %d\n", p[0], p[1]); if (*p == 0) break; 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: 216499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0507EC35254 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 DA73120726 for ; Sun, 9 Feb 2020 16:59:18 +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: 216498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4764C35250 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 9679720726 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");