[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <wiho9is602c.fsf@dev-r-vrt-156.mtr.labs.mlnx>
Date: Mon, 09 Apr 2018 15:23:07 +0300
From: Petr Machata <petrm@...lanox.com>
To: Arend van Spriel <arend.vanspriel@...adcom.com>
Cc: Himanshu Jha <himanshujha199640@...il.com>,
franky.lin@...adcom.com, hante.meuleman@...adcom.com,
chi-hsien.lin@...ress.com, wright.feng@...ress.com,
kvalo@...eaurora.org, johannes.berg@...el.com,
linux-wireless@...r.kernel.org,
brcm80211-dev-list.pdl@...adcom.com,
brcm80211-dev-list@...ress.com, netdev@...r.kernel.org
Subject: Re: Passing uninitialised local variable
Arend van Spriel <arend.vanspriel@...adcom.com> writes:
> On 3/28/2018 1:20 PM, Himanshu Jha wrote:
>> I recently found that a local variable in passed uninitialised to the
>> function at
>>
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:2950
>>
>> u32 var;
>> err = brcmf_fil_iovar_int_get(ifp, "dtim_assoc", &var);
>>
>> s32
>> brcmf_fil_iovar_int_get(struct brcmf_if *ifp, char *name, u32 *data)
>> {
>> __le32 data_le = cpu_to_le32(*data);
>> }
>>
>> We can cleary see that 'var' in used uninitialised in the very first line
>> which is an undefined behavior.
>
> Why undefined? We copy some stack data and we do transfer that to the device. However in this case
> the device does nothing with it and it is simply overwritten by the response.
"Undefined behavior" is a technical term for when there are no
guarantees as to what the result of executing a given code will be. None
at all--it might for example abort, and that would be perfectly valid as
well. (To be clear, this is not about the device, but about the CPU that
this code runs on.)
Uninitialized reads are one example of a code construct that invokes
undefined behavior.
Thanks,
Petr
Powered by blists - more mailing lists