From: Dan Carpenter <dan.carpenter@oracle.com>
To: Colin Ian King <colin.king@canonical.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: static analysis bug report: staging r8712u memcpy of uninitialized variable
Date: Wed, 20 Mar 2019 11:58:59 +0300 [thread overview]
Message-ID: <20190320085858.GF2202@kadam> (raw)
In-Reply-To: <2b54dc2d-7509-dc76-b730-4c8d66f81226@canonical.com>
On Mon, Mar 18, 2019 at 11:20:51AM +0000, Colin Ian King wrote:
> Hi,
>
> Static analysis with cppcheck found a couple of interesting issues with
> memcpy'ing of an uninitialized variable. Two occurrences of the same
> issue are found in drivers/staging/rtl8712/rtl8712_cmd.c in functions
> read_bbreg_hdl and read_rfreg_hdl.
>
> For example:
>
> static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
> {
> u32 val;
> void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj
> *pcmd);
> struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
>
> if (pcmd->rsp && pcmd->rspsz > 0)
> memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);
>
> ....
>
> }
>
> I don't understand why the contents of val is being memcpy'd to
> pcmd->rsp, especially when val is uninitialized and hence contains
> garbage. Any ideas?
>
The concern would be that it's reading a user specified amount of
stack memory to pcmd->rsp and that sounds like an information leak.
The pcmd_callback function pointer is always r8712_getbbrfreg_cmdrsp_callback()
which frees pcmd->parmbuf and pcmd but leaks pcmd->rsp. I don't see
a way for anyone to access the ->rsp memory so probably there aren't any
security implications.
Anyway, let me send a patch.
regards,
dan carpenter
next prev parent reply other threads:[~2019-03-20 8:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 11:20 static analysis bug report: staging r8712u memcpy of uninitialized variable Colin Ian King
2019-03-20 8:58 ` Dan Carpenter [this message]
2019-03-21 6:26 ` [PATCH] staging: rtl8712: uninitialized memory in read_bbreg_hdl() Dan Carpenter
2019-03-21 6:45 ` Dan Carpenter
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=20190320085858.GF2202@kadam \
--to=dan.carpenter@oracle.com \
--cc=Larry.Finger@lwfinger.net \
--cc=colin.king@canonical.com \
--cc=devel@driverdev.osuosl.org \
--cc=linux-kernel@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