Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp352177pxj; Tue, 18 May 2021 05:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyquOODHV+fXR24uLE4M0qYpuvkZZNX7G1wmiSswGn8LKuqEshmlqMiT2reZXk9/8AgQmTR X-Received: by 2002:a05:6402:26d1:: with SMTP id x17mr6613636edd.14.1621339319294; Tue, 18 May 2021 05:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621339319; cv=none; d=google.com; s=arc-20160816; b=WTY90nisgpeYHJFRN3FRjjVzzPGN2RcegraE0gY6cz0fPzJVW2INZwhQT3vKhYGS1d r6KEGKB9A1Ui/OxVaDwAn4g4skDMtDO8O77oKc5Teh2P3NKHO2OvHpyDMWwR5F02Hrok Kk117Rt1OcG1AtgufIkyDFkvWVXRWVV9fXGnzGtM0c0F6J0WpUqXZY4BAeYz5b9SmEa0 CKuTb5S0wAFi6gYJbnTAjJ2OBrVeiSxMHTVS2u0iS+aKZqZLTekdZVgldABmpJPg4bOt ibyZFSXF6J/DjG9dsYN2C9ub5mHXV2jbloM0jaQ0Ig8KGU1ugyMh88AoscvYmCUkV3Vq cx+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e7W8xPP6ySyJbXaCBigAf4GSgTjsAHIMNodmQl2yZLU=; b=zmEmF0fUqJlJgJEIBzPWLqXbzsGpCSVzUWxtRosht/gpUenxqpmItuBMRMvX/X6sAQ Xqrr+c3SWqycmsOGuVX2qYR6bEmTD7A+oSKKpvEjLOTMY9/ftmliofXHm5cQmMObh8fe 8TFHI2X9/vuMoVMgNr6NcqrG4coxP2bdaJAMnd5KwKDCB/lfAhd79k4HecdGKZZtp1EB 4iT5x1rUW4pdTUG27Fi/A2xOLZMhXUF9/vWIz3mItceu/sQw+w+iH40TEJCrPGEzuYEo 1dYBLVoTXJesOgdK0Kzc/vrDP1GHb/5heG9lD0LNRGI6+0PYl8DLFBZ9Mb/sBmTXvmCg +DQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b2uHkqvu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m5si17364421eds.484.2021.05.18.05.01.29; Tue, 18 May 2021 05:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b2uHkqvu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244098AbhEQP05 (ORCPT + 99 others); Mon, 17 May 2021 11:26:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:37252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242941AbhEQPMf (ORCPT ); Mon, 17 May 2021 11:12:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 90E0161C31; Mon, 17 May 2021 14:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261884; bh=lmCl/8+UbLLfBdAII2ABQDwTMsu3Sc1/051k2dkBo2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b2uHkqvuFqcRaE2McACV2jpEqFOtS6hy/lyBq3cM0fF3b3e1QvFtYVT1l7VO1J+5p EacYCvmFGPfPHuT8ZuBIT8MpnqrS89JMRrv2oqMuA8c3cesIBqcezZZgTwNbVQep5x 3vilUFcAqqAm+S8qL0MY2k8/JYjg7xn/fH84TbYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Gibson , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 080/289] qtnfmac: Fix possible buffer overflow in qtnf_event_handle_external_auth Date: Mon, 17 May 2021 16:00:05 +0200 Message-Id: <20210517140307.881242559@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lee Gibson [ Upstream commit 130f634da1af649205f4a3dd86cbe5c126b57914 ] Function qtnf_event_handle_external_auth calls memcpy without checking the length. A user could control that length and trigger a buffer overflow. Fix by checking the length is within the maximum allowed size. Signed-off-by: Lee Gibson Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20210419145842.345787-1-leegib@gmail.com Signed-off-by: Sasha Levin --- drivers/net/wireless/quantenna/qtnfmac/event.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c index c775c177933b..8dc80574d08d 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/event.c +++ b/drivers/net/wireless/quantenna/qtnfmac/event.c @@ -570,8 +570,10 @@ qtnf_event_handle_external_auth(struct qtnf_vif *vif, return 0; if (ev->ssid_len) { - memcpy(auth.ssid.ssid, ev->ssid, ev->ssid_len); - auth.ssid.ssid_len = ev->ssid_len; + int len = clamp_val(ev->ssid_len, 0, IEEE80211_MAX_SSID_LEN); + + memcpy(auth.ssid.ssid, ev->ssid, len); + auth.ssid.ssid_len = len; } auth.key_mgmt_suite = le32_to_cpu(ev->akm_suite); -- 2.30.2