From patchwork Thu Feb 13 15:21:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 231530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61A83C2BA83 for ; Thu, 13 Feb 2020 15:37:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37A0120675 for ; Thu, 13 Feb 2020 15:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581608265; bh=Y74Xd+mVklbZULUCpaI/t71V7iNTRldQmCAkpffYaHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=trx04p+JscuyLbreIrM1k1AzrwOK2h6RCxOzJnE2Sqrfy+EtzaaUaQQEBogVyCWzY 0SmsXNSUbnR2h6RN2Kl1IRko/X3JCqCKCtmdCPbAw/kBAeNQgyjCtiC0NpUv0PgQZh HkY5jwn1oTNyxgdEHPEhkSgHk0YFFIZVVZ0XogOc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728869AbgBMPhj (ORCPT ); Thu, 13 Feb 2020 10:37:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:60186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729715AbgBMP3W (ORCPT ); Thu, 13 Feb 2020 10:29:22 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D7E34206DB; Thu, 13 Feb 2020 15:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607762; bh=Y74Xd+mVklbZULUCpaI/t71V7iNTRldQmCAkpffYaHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0e6+fb333fnkQIeJHYlR6os5HXHO2Hg3gEbvZwImTUeLv9TM0E/otZ0Ec0nmEFC7 aheElmu+DDlcE/BXLTyz12f1r66EjidYH/Sn0ELiS1IYO8MIPJMABWJoF+afno6e2f sayme/ewpJcwJRk24JVyAJex4ji4QQUxH096Is8k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qing Xu , Kalle Valo , Sasha Levin Subject: [PATCH 5.5 118/120] mwifiex: Fix possible buffer overflows in mwifiex_cmd_append_vsie_tlv() Date: Thu, 13 Feb 2020 07:21:54 -0800 Message-Id: <20200213151939.700519401@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151901.039700531@linuxfoundation.org> References: <20200213151901.039700531@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qing Xu [ Upstream commit b70261a288ea4d2f4ac7cd04be08a9f0f2de4f4d ] mwifiex_cmd_append_vsie_tlv() 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: Qing Xu Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/mwifiex/scan.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index 98f942b797f7b..a7968a84aaf88 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -2884,6 +2884,13 @@ mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, vs_param_set->header.len = cpu_to_le16((((u16) priv->vs_ie[id].ie[1]) & 0x00FF) + 2); + if (le16_to_cpu(vs_param_set->header.len) > + MWIFIEX_MAX_VSIE_LEN) { + mwifiex_dbg(priv->adapter, ERROR, + "Invalid param length!\n"); + break; + } + memcpy(vs_param_set->ie, priv->vs_ie[id].ie, le16_to_cpu(vs_param_set->header.len)); *buffer += le16_to_cpu(vs_param_set->header.len) +