BACKPORT: FROMGIT: mwifiex: Fix possible buffer overflows in mwifiex_cmd_append_vsie_tlv()

[ 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 <m1s5p6688@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 4dd90d14f902074f18238dc104868debbd3cd250
 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.4.y)

BUG=chromium:1080618
TEST=Wireless tests

Change-Id: I32491d8dead47f0b899da383ff263e41f100baff
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2194562
Reviewed-by: Brian Norris <briannorris@chromium.org>
1 file changed