|
Takashi Iwai |
e76663 |
From 315cee426f87658a6799815845788fde965ddaad Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
e76663 |
From: Denis Efremov <efremov@linux.com>
|
|
Takashi Iwai |
e76663 |
Date: Mon, 30 Sep 2019 23:31:47 +0300
|
|
Takashi Iwai |
e76663 |
Subject: [PATCH] ar5523: check NULL before memcpy() in ar5523_cmd()
|
|
Takashi Iwai |
e76663 |
Git-commit: 315cee426f87658a6799815845788fde965ddaad
|
|
Takashi Iwai |
e76663 |
Patch-mainline: v5.5-rc1
|
|
Takashi Iwai |
e76663 |
References: bsc#1051510
|
|
Takashi Iwai |
e76663 |
|
|
Takashi Iwai |
e76663 |
memcpy() call with "idata == NULL && ilen == 0" results in undefined
|
|
Takashi Iwai |
e76663 |
behavior in ar5523_cmd(). For example, NULL is passed in callchain
|
|
Takashi Iwai |
e76663 |
"ar5523_stat_work() -> ar5523_cmd_write() -> ar5523_cmd()". This patch
|
|
Takashi Iwai |
e76663 |
adds ilen check before memcpy() call in ar5523_cmd() to prevent an
|
|
Takashi Iwai |
e76663 |
undefined behavior.
|
|
Takashi Iwai |
e76663 |
|
|
Takashi Iwai |
e76663 |
Cc: Pontus Fuchs <pontus.fuchs@gmail.com>
|
|
Takashi Iwai |
e76663 |
Cc: Kalle Valo <kvalo@codeaurora.org>
|
|
Takashi Iwai |
e76663 |
Cc: "David S. Miller" <davem@davemloft.net>
|
|
Takashi Iwai |
e76663 |
Cc: David Laight <David.Laight@ACULAB.COM>
|
|
Takashi Iwai |
e76663 |
Cc: stable@vger.kernel.org
|
|
Takashi Iwai |
e76663 |
Signed-off-by: Denis Efremov <efremov@linux.com>
|
|
Takashi Iwai |
e76663 |
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
|
|
Takashi Iwai |
e76663 |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
e76663 |
|
|
Takashi Iwai |
e76663 |
---
|
|
Takashi Iwai |
e76663 |
drivers/net/wireless/ath/ar5523/ar5523.c | 3 ++-
|
|
Takashi Iwai |
e76663 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
Takashi Iwai |
e76663 |
|
|
Takashi Iwai |
e76663 |
diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c
|
|
Takashi Iwai |
e76663 |
index b94759daeacc..da2d179430ca 100644
|
|
Takashi Iwai |
e76663 |
--- a/drivers/net/wireless/ath/ar5523/ar5523.c
|
|
Takashi Iwai |
e76663 |
+++ b/drivers/net/wireless/ath/ar5523/ar5523.c
|
|
Takashi Iwai |
e76663 |
@@ -255,7 +255,8 @@ static int ar5523_cmd(struct ar5523 *ar, u32 code, const void *idata,
|
|
Takashi Iwai |
e76663 |
|
|
Takashi Iwai |
e76663 |
if (flags & AR5523_CMD_FLAG_MAGIC)
|
|
Takashi Iwai |
e76663 |
hdr->magic = cpu_to_be32(1 << 24);
|
|
Takashi Iwai |
e76663 |
- memcpy(hdr + 1, idata, ilen);
|
|
Takashi Iwai |
e76663 |
+ if (ilen)
|
|
Takashi Iwai |
e76663 |
+ memcpy(hdr + 1, idata, ilen);
|
|
Takashi Iwai |
e76663 |
|
|
Takashi Iwai |
e76663 |
cmd->odata = odata;
|
|
Takashi Iwai |
e76663 |
cmd->olen = olen;
|
|
Takashi Iwai |
e76663 |
--
|
|
Takashi Iwai |
e76663 |
2.16.4
|
|
Takashi Iwai |
e76663 |
|