Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp655046pxv; Thu, 15 Jul 2021 12:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOqvDJ2bvDKXYAHzClABiPejlbxdSs4JrVih5tzn0VERJx1Xyh00lFCf6H7ZUThRofxgIJ X-Received: by 2002:a05:6402:26ca:: with SMTP id x10mr9277291edd.319.1626377775050; Thu, 15 Jul 2021 12:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377775; cv=none; d=google.com; s=arc-20160816; b=JAsRoVNmijifYoKkL74aQN9mFNVlZj6+j9LgW3OQtJWSalA4Mzu3hIQ39XRfW3SRlq YuLclLUauvNBg6Vgrf3KB02DBDjNvYa2gWwjAqQJucOK6HUn5yurY0OXBNF/Vh7P5Wuj AZDkzDQZsMTxUqOvOxkXzsIhDNQBcNN8DSm/4ERXLFZc5zTSLCLxzlB45EAMfcbvM2uP sxV5fOyzXSlfL8WDxyK7ksQaFpfDSQ8j4qNiC6t/RLhza/qPIzto6BzynKdlkyidQTMn LlUdg+ax4HypRc7i4GU6O9ujtFk2m5Wa15eihHOQQzpgeUQ0lVYa4UPABZ3QjSP0f+P+ 1Uuw== 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=4kOsk94owB5VtUUpf2UeEY4Gts97jN89L0cMQbt9VdU=; b=owSvwmpGufhk1lsQElFCTDE0GepMyyRFccV6IZsvm9w/3lSfDWni04zCyVDKT45PLK vzjf3kKCa3EL/qWVKHZM5u7n3D+NUuJuKhvjpa+C0RAo53miLTtkCWPbwzX4Dcs3BZjl e1jMY0VPwy5DH+JIIH3OIG1RIti/Z5C9Kp+iuW4c0HLmTrYt3fvlfC4qyEqExMjl5zXq szml7FBeJpQ3FKXirhbSFmLuxrWKnX3MbwCUjijSmv574IEFVoUQ5JT5e3bwe9CRbYUK i7FGgD0EKO6hvapjrw240QdUbu6dUyLsmcGJci1NRmEESwflVhi2s9h8QvmIuSNXxotZ DXGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D7OEy3gh; 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 m21si8813953edj.470.2021.07.15.12.35.52; Thu, 15 Jul 2021 12:36:15 -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=D7OEy3gh; 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 S244057AbhGOTc3 (ORCPT + 99 others); Thu, 15 Jul 2021 15:32:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:45648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243964AbhGOTK0 (ORCPT ); Thu, 15 Jul 2021 15:10:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25436613D0; Thu, 15 Jul 2021 19:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376047; bh=iNcNQir2cRVMu562KVKOKY2dPsh8LJRdvfF8o5bwC1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D7OEy3ghioN73Dclt0r8kALysymhNKn8pf5EUhiH5256fUB4c6Zb87X5uNradidS/ SVo5nHcKwkc1FDYrmseki96k7mdh4XuOW/8aD7aZ1HxdmPanNb2LRFqfww6nLIpYJV CrfYQrKu6Y+lvAcbm19JTRaE4jLOouBeiGPCG2MU= 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.13 103/266] wl1251: Fix possible buffer overflow in wl1251_cmd_scan Date: Thu, 15 Jul 2021 20:37:38 +0200 Message-Id: <20210715182632.166400618@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 d10a87a3535cce2b890897914f5d0d83df669c63 ] Function wl1251_cmd_scan calls memcpy without checking the length. Harden 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/20210428115508.25624-1-leegib@gmail.com Signed-off-by: Sasha Levin --- drivers/net/wireless/ti/wl1251/cmd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ti/wl1251/cmd.c b/drivers/net/wireless/ti/wl1251/cmd.c index 498c8db2eb48..d7a869106782 100644 --- a/drivers/net/wireless/ti/wl1251/cmd.c +++ b/drivers/net/wireless/ti/wl1251/cmd.c @@ -454,9 +454,12 @@ int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len, cmd->channels[i].channel = channels[i]->hw_value; } - cmd->params.ssid_len = ssid_len; - if (ssid) - memcpy(cmd->params.ssid, ssid, ssid_len); + if (ssid) { + int len = clamp_val(ssid_len, 0, IEEE80211_MAX_SSID_LEN); + + cmd->params.ssid_len = len; + memcpy(cmd->params.ssid, ssid, len); + } ret = wl1251_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd)); if (ret < 0) { -- 2.30.2