Re: [REGRESSION] brcmfmac: NULL pointer deference starting next-20181107

From: Jon Hunter
Date: Tue Nov 13 2018 - 08:21:28 EST



On 13/11/2018 10:40, Hans de Goede wrote:
> Hi,
>
> On 13-11-18 11:24, Arend van Spriel wrote:
>> + Ard as this involves EFI.
>>
>> On 11/12/2018 2:24 PM, Jon Hunter wrote:
>>> Hi Hans, Kalle,
>>>
>>> Starting with next-20181107 I am seeing the following NULL pointer
>>> deference on Tegra (note the firmware is missing on this board) ...
>>>
>>> [ÂÂ 14.072883] brcmfmac: brcmf_fw_alloc_request: using
>>> brcm/brcmfmac4329-sdio for chip BCM4329/3
>>>
>>> [ÂÂ 14.130287] brcmfmac mmc1:0001:1: Direct firmware load for
>>> brcm/brcmfmac4329-sdio.nvidia,cardhu-a04.txt failed with error -2
>>>
>>> [ÂÂ 14.156283] brcmfmac mmc1:0001:1: Direct firmware load for
>>> brcm/brcmfmac4329-sdio.txt failed with error -2
>>>
>>> [ÂÂ 14.177769] Unable to handle kernel NULL pointer dereference at
>>> virtual address 00000008
>>>
>>> [ÂÂ 14.197303] pgd = 60bfa5f1
>>>
>>> [ÂÂ 14.211842] [00000008] *pgd=00000000
>>>
>>> [ÂÂ 14.227373] Internal error: Oops: 5 [#1] SMP ARM
>>>
>>> [ÂÂ 14.244244] Modules linked in: brcmfmac sha256_generic sha256_arm
>>> snd cfg80211 brcmutil soundcore snd_soc_tegra30_ahub tegra_wdt
>>>
>>> [ÂÂ 14.269109] CPU: 1 PID: 114 Comm: kworker/1:2 Not tainted
>>> 4.20.0-rc1-next-20181107-gd881de3 #1
>>>
>>> [ÂÂ 14.269114] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
>>>
>>> [ÂÂ 14.269154] Workqueue: events request_firmware_work_func
>>>
>>> [ÂÂ 14.269177] PC is at efivar_entry_size+0x28/0x90
>>>
>>> [ÂÂ 14.269362] LR is at brcmf_fw_complete_request+0x3f8/0x8d4 [brcmfmac]
>>>
>>> [ÂÂ 14.269369] pc : [<c0c40718>]ÂÂÂ lr : [<bf2a3ef4>]ÂÂÂ psr: a00d0113
>>>
>>> [ÂÂ 14.269374] sp : ede7fe28Â ip : ee983410Â fp : c1787f30
>>>
>>> [ÂÂ 14.269378] r10: 00000000Â r9 : 00000000Â r8 : bf2b2258
>>>
>>> [ÂÂ 14.269384] r7 : ee983000Â r6 : c1604c48Â r5 : ede7fe88Â r4 :
>>> edf337c0
>>>
>>> [ÂÂ 14.269389] r3 : 00000000Â r2 : 00000000Â r1 : ede7fe88Â r0 :
>>> c17712c8
>>>
>>
>> Hi Jon,
>>
>> I tried building drivers/firmware/efi/vars.c using tegra_defconfig.
>> Had to enable CONFIG_EFI. So the null pointer access is a 0x00000008
>> so I looked at the disassembly below:
>>
>> int efivar_entry_size(struct efivar_entry *entry, unsigned long *size)
>> {
>> ÂÂÂÂÂ 310:ÂÂÂÂÂÂ e1a05001ÂÂÂÂÂÂÂ movÂÂÂÂ r5, r1
>> ÂÂÂÂÂÂÂÂ const struct efivar_operations *ops = __efivars->ops;
>> ==>Â 314:ÂÂÂÂÂÂ e5936008ÂÂÂÂÂÂÂ ldrÂÂÂÂ r6, [r3, #8]
>>
>> So I think __efivars is NULL on your platform. It is private to the
>> source file. Not sure how the driver should deal with this. Maybe use
>> efi_enabled() but not sure what feature to use. My best bet would be
>> EFI_RUNTIME_SERVICES.
>
> Ah right, thank you for catching this I had looking into this
> on my TODO list, but you beat me to it.
>
> IMHO the best fix here would be to modify efivar_entry_size(),
> adding:
>
> ÂÂÂÂif (!ops)
> ÂÂÂÂÂÂÂ return -ENOENT;
>
> Which makes it return the same error as when we do have efivar
> support but the requested variable is not found.

So the above did not work. I see a patch from Arend and I will give this
a try.

Cheers
Jon

--
nvpublic