From: David Laight <David.Laight@ACULAB.COM>
To: 'Denis Efremov' <efremov@linux.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Pontus Fuchs <pontus.fuchs@gmail.com>,
Kalle Valo <kvalo@codeaurora.org>,
"David S. Miller" <davem@davemloft.net>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] ar5523: check NULL before memcpy() in ar5523_cmd()
Date: Mon, 30 Sep 2019 15:35:42 +0000 [thread overview]
Message-ID: <230cd4f790544b01a26afa26e4186454@AcuMS.aculab.com> (raw)
In-Reply-To: <20190930140207.28638-1-efremov@linux.com>
From: Denis Efremov
> Sent: 30 September 2019 15:02
>
> memcpy() call with "idata == NULL && ilen == 0" results in undefined
> behavior in ar5523_cmd(). For example, NULL is passed in callchain
> "ar5523_stat_work() -> ar5523_cmd_write() -> ar5523_cmd()". This patch
> adds idata check before memcpy() call in ar5523_cmd() to prevent an
> undefined behavior.
>
...
> Signed-off-by: Denis Efremov <efremov@linux.com>
> ---
> drivers/net/wireless/ath/ar5523/ar5523.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c
> index b94759daeacc..f25af5bc5282 100644
> --- a/drivers/net/wireless/ath/ar5523/ar5523.c
> +++ b/drivers/net/wireless/ath/ar5523/ar5523.c
> @@ -255,7 +255,8 @@ static int ar5523_cmd(struct ar5523 *ar, u32 code, const void *idata,
>
> if (flags & AR5523_CMD_FLAG_MAGIC)
> hdr->magic = cpu_to_be32(1 << 24);
> - memcpy(hdr + 1, idata, ilen);
> + if (idata)
> + memcpy(hdr + 1, idata, ilen);
That would be better as if (ilen) ...
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2019-09-30 15:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 14:02 [PATCH] ar5523: check NULL before memcpy() in ar5523_cmd() Denis Efremov
2019-09-30 15:35 ` David Laight [this message]
2019-09-30 20:31 ` [PATCH v2] " Denis Efremov
2019-10-02 17:22 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=230cd4f790544b01a26afa26e4186454@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=davem@davemloft.net \
--cc=efremov@linux.com \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pontus.fuchs@gmail.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).