[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190320085858.GF2202@kadam>
Date: Wed, 20 Mar 2019 11:58:59 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Colin Ian King <colin.king@...onical.com>
Cc: Larry Finger <Larry.Finger@...inger.net>,
"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: static analysis bug report: staging r8712u memcpy of
uninitialized variable
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
Powered by blists - more mailing lists