Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5456548pxu; Tue, 22 Dec 2020 18:36:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWQZun8jmY8/zSlkjXRHfOi/AnKiALHCiPBTPTj598IugfCz1SpIf3dmki1ZB9gTfdUR/4 X-Received: by 2002:a17:906:e250:: with SMTP id gq16mr21608911ejb.382.1608690978329; Tue, 22 Dec 2020 18:36:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608690978; cv=none; d=google.com; s=arc-20160816; b=CL0qntwvLLZVBmv+l++5k8LskjozGSSIyar1pdIK2BGjNRUk7IKZ4xNh8wpV7QX+rK mFmYa7qKSXDrP/HF3Eo3b3qK6BfRab9lpFn9fyfeLGTooi2r90dwew/MLI+1137jShAX wPds2mWwQBzPGnq5GM4J3jX7BOX7SETYOzAbzcmA5TlIJ5IVlRRYoE7R76Iiw6ygceCc /tbDxE7cS8KOuyh6lY+gUUiLnGVti4ta5sPpAO23NIvXZA/pE9KPuUmsYS9rSvlzBoA7 7YpIoBB7Ora0k/jPWs36pD8tHUDlDy7i9jnk1nXDSBuv/EU2UuNrpI+jTsDo5iCmFVLu w+bg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fgUnxgoUMUjZJFnviFvAHZFI6mxDHy6tZsE8zUFbA0U=; b=ELOAfFd83oS/Txq0jzUdk3tRN/DeABPvyc+YnYtVRvkpYoaU2zevgv5IDT698GVnP2 D2gPPq0J568gS5ECDz5H6+6brFCgT2VTnmKJeZEvdCFInVT4AiOZD+PF/whF5TsFal/O MJEa25dVKZBAGSkSFPQQvWf/PeXxvWZpKWvgEBXWVNoHHsw65DZy86O2OLZaVkbV+5au vtK4NYVQ+46XFWsYuONI2UQ4PitZ8wrHfVdjJGp6K19u2Txzx7DVO/9wJ+JE+EEuDvxM XMSpo8nl1rM5nsxvRzsdb8smAMaNIMsC3H4LcTLcaGWeexddTmg+xgO5RNtWOIyeifEj FxpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VOSVhB3+; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co17si13106493edb.518.2020.12.22.18.35.56; Tue, 22 Dec 2020 18:36:18 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=VOSVhB3+; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729743AbgLWCfy (ORCPT + 99 others); Tue, 22 Dec 2020 21:35:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:54924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730281AbgLWCYk (ORCPT ); Tue, 22 Dec 2020 21:24:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C1F2223383; Wed, 23 Dec 2020 02:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690239; bh=ZqsyhDJr975uH78eq9vlqfIjc4P44FyApTZEkqL50qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VOSVhB3+A9Xcnpus0lrHx+bRXtGOR3SaYiSeizUeiXsNgnQWJWHIYRdnMMDeMtu+M VadgSvSQ0qEacp5SVh6Tdrabfszl5wygRpXlThSJ6XKs0VkndQqZm07NzVannNgqbe QhHJu212kdwZeD4ieVP2TdxKaiofOE9X0y5yLkk4u4Bbfuqw3nangIAU2S9sUvIJr9 sP6Jwbk3IkKjgYoS8cj6WYCmdvRhDSfC49xIf+UCMGv8+J5Pm8Jq53yrmgKJF452YO OaEasVYKsycbdf6A/YJDUhN3kCrNDECK0VDHxA91JoXFfedoX3iRJsbaATft+UO0Bj Yf9ACnpVFSM5w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhang Xiaohui , Kalle Valo , Sasha Levin , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 53/66] mwifiex: Fix possible buffer overflows in mwifiex_cmd_802_11_ad_hoc_start Date: Tue, 22 Dec 2020 21:22:39 -0500 Message-Id: <20201223022253.2793452-53-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Xiaohui [ Upstream commit 5c455c5ab332773464d02ba17015acdca198f03d ] mwifiex_cmd_802_11_ad_hoc_start() calls memcpy() without checking the destination size may trigger a buffer overflower, which a local user could use to cause denial of service or the execution of arbitrary code. Fix it by putting the length check before calling memcpy(). Signed-off-by: Zhang Xiaohui Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201206084801.26479-1-ruc_zhangxiaohui@163.com Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/mwifiex/join.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/join.c b/drivers/net/wireless/marvell/mwifiex/join.c index d87aeff70cefb..c2cb1e711c06e 100644 --- a/drivers/net/wireless/marvell/mwifiex/join.c +++ b/drivers/net/wireless/marvell/mwifiex/join.c @@ -877,6 +877,8 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, memset(adhoc_start->ssid, 0, IEEE80211_MAX_SSID_LEN); + if (req_ssid->ssid_len > IEEE80211_MAX_SSID_LEN) + req_ssid->ssid_len = IEEE80211_MAX_SSID_LEN; memcpy(adhoc_start->ssid, req_ssid->ssid, req_ssid->ssid_len); mwifiex_dbg(adapter, INFO, "info: ADHOC_S_CMD: SSID = %s\n", -- 2.27.0