From patchwork Thu Jul 6 22:43:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jouni Malinen X-Patchwork-Id: 9829177 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E1655602F0 for ; Thu, 6 Jul 2017 22:45:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D022C28544 for ; Thu, 6 Jul 2017 22:45:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1E4628542; Thu, 6 Jul 2017 22:45:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46A5028542 for ; Thu, 6 Jul 2017 22:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752737AbdGFWph (ORCPT ); Thu, 6 Jul 2017 18:45:37 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:2467 "EHLO alexa-out-lv-02.qualcomm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751619AbdGFWph (ORCPT ); Thu, 6 Jul 2017 18:45:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qca.qualcomm.com; i=@qca.qualcomm.com; q=dns/txt; s=qcdkim; t=1499381137; x=1530917137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RciZAJe+tlhuhIDKRJmlvRorWhWOUIkB63jltGcXXfk=; b=QqX1+CXjd2Q0bWEC1BYn9nmpcR0GbS60B3Ko6X6Mu7yUAIV0D65IQN+m oi7QYogG1SYz69Xgil/Gg1dI6JclIZ/WJSqWDyi3q0R9K+D1wI2ytXFzt cyZIxbvymEOrpbk7PsXUA6U0NnNiG0a/VboPk5mD6cMkgkGx1spUbfGk8 M=; X-IronPort-AV: E=Sophos;i="5.40,319,1496127600"; d="scan'208";a="345325" Received: from ironmsg02-r-new.qualcomm.com (HELO ironmsg02-R.qualcomm.com) ([10.53.140.106]) by alexa-out-lv-02.qualcomm.com with ESMTP; 06 Jul 2017 15:45:36 -0700 X-IronPort-AV: E=McAfee;i="5800,7501,8583"; a="993966557" X-MGA-submission: =?us-ascii?q?MDHlhws8pTwPjl9UEMlf7Azyt2TQElBhwhdcKp?= =?us-ascii?q?YH0KYPZJkvSjCZ1NgwDs9be0wvHYdC1B3hkTloruBP6hZ3GKypW+odr4?= =?us-ascii?q?S2kE/RHHms3JNr/vqUEUBDOM0SmqiYcNNdg3WfOjrwQDYF6Fl3cW4TkN?= =?us-ascii?q?IZ?= Received: from nasanexm01g.na.qualcomm.com ([10.85.0.33]) by ironmsg02-R.qualcomm.com with ESMTP/TLS/RC4-SHA; 06 Jul 2017 15:45:36 -0700 Received: from euamsexm01e.eu.qualcomm.com (10.251.127.42) by NASANEXM01G.na.qualcomm.com (10.85.0.33) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 6 Jul 2017 15:45:35 -0700 Received: from jouni.qca.qualcomm.com (10.80.80.8) by euamsexm01e.eu.qualcomm.com (10.251.127.42) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Fri, 7 Jul 2017 00:45:30 +0200 From: Jouni Malinen To: Johannes Berg CC: , Srinivas Dasari , Jouni Malinen Subject: [PATCH 4/4] cfg80211: Validate frequencies nested in NL80211_ATTR_SCAN_FREQUENCIES Date: Fri, 7 Jul 2017 01:43:42 +0300 Message-ID: <1499381022-5389-4-git-send-email-jouni@qca.qualcomm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499381022-5389-1-git-send-email-jouni@qca.qualcomm.com> References: <1499381022-5389-1-git-send-email-jouni@qca.qualcomm.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01G.na.qualcomm.com (10.85.0.33) To euamsexm01e.eu.qualcomm.com (10.251.127.42) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Srinivas Dasari validate_scan_freqs() retrieves frequencies from attributes nested in the attribute NL80211_ATTR_SCAN_FREQUENCIES with nla_get_u32(), which reads 4 bytes from each attribute without validating the size of data received. Attributes nested in NL80211_ATTR_SCAN_FREQUENCIES don't have an nla policy. Validate size of each attribute before parsing to avoid potential buffer overread. Fixes: 2a519311926 ("cfg80211/nl80211: scanning (and mac80211 update to use it)") Cc: stable@vger.kernel.org Signed-off-by: Srinivas Dasari Signed-off-by: Jouni Malinen --- net/wireless/nl80211.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 0a63b95..740d3c1 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -6469,6 +6469,9 @@ static int validate_scan_freqs(struct nlattr *freqs) struct nlattr *attr1, *attr2; int n_channels = 0, tmp1, tmp2; + nla_for_each_nested(attr1, freqs, tmp1) + if (nla_len(attr1) != sizeof(u32)) + return 0; nla_for_each_nested(attr1, freqs, tmp1) { n_channels++; /*