Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3027239pxj; Mon, 17 May 2021 15:56:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA9vRxHJcM9oiAABdNsfVxt2BR9HPWOdU43zlsJ+inH/55QgjvB3qajiNf0d7yexAp4jMD X-Received: by 2002:a5e:8305:: with SMTP id x5mr1864331iom.112.1621292204937; Mon, 17 May 2021 15:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621292204; cv=none; d=google.com; s=arc-20160816; b=f+EtGDuewQkQcO6Vu/OOeTs8L2we1XE5u0i2kfxYfArNsI1OAoxdJ0gYRWJdgPpQEs BfBdnpJ28g8BKaa/h60UXMJrx0PRJ6FonU/By0DxXELZy3xDhsHJbDnwq+md3ZjTpvzq k6S9MJOR658ylvFr3XkJYsh/rlDhzAUBqpMi2TT61QrK2esFEfHQeS+cDUTowWPfBt+l kWFvi6Dej3DwpbMg0eNgTdcNCI6G1mWqGXdtvovPf5guAmIiVq1HMUb+uH6wTqfFxk8G O9uenFFAy0hQrV//tC5BP3jA+ZHRmCr5Pb1XOUD6AyYOPXs6NoX1RTQ1Hc9iY8g0sAVq ULwg== 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=mP9wyhgVc6IhI8OLiYv8DyiDwQ0TmaSo3tgnzyj+9xAxr2GbIeYLLk9ab9UHb/bEQv 9QQLw6NOaNFGjMcS3c+RmQvxzwHSGR7eXEJOAMDRnVduQhWIDhDMc3TsAsXEzwaYemlt jltQ9UrquGdFuPZUxn39+6cLYdBEU/YN5/7Edb0aZZ1IsRvmoSOaqb0uSv0FPUavB63x b1Z2xwwHCJwaacyMZmpqqBK4hjZfTmYphimu6lVY19kn04udVyc++2A41kDOa4T8x8wT PsFJyPSuCPIFNGg/Fox0mszYQPI2rE8nbhwUNM1EI7qI7R2eYU9IZ8uZRY9qDj8ZYPcE R2zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jEuP2a8F; 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 b26si3657810ios.29.2021.05.17.15.56.32; Mon, 17 May 2021 15:56:44 -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=jEuP2a8F; 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 S237216AbhEQOSd (ORCPT + 99 others); Mon, 17 May 2021 10:18:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:44940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238655AbhEQOQN (ORCPT ); Mon, 17 May 2021 10:16:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 676EE61404; Mon, 17 May 2021 14:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260574; bh=lmCl/8+UbLLfBdAII2ABQDwTMsu3Sc1/051k2dkBo2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jEuP2a8FAfVV6IfkD8DZsegzEEnxdqq7JKzBv8qAwprIHWNMw2K+YNi4t2dF553KB 7glrnGRCaIM1sIConkR9YEiHLboDDGNrQBc1ny4lIlT24V5NnamrTyXaU8uA6cZu9F zAVYgHEL4Vf00lUaieuUMX2aHPa4MTcuzoKdaeww= 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.12 109/363] qtnfmac: Fix possible buffer overflow in qtnf_event_handle_external_auth Date: Mon, 17 May 2021 15:59:35 +0200 Message-Id: <20210517140306.294612782@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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