lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 28 Nov 2019 09:24:12 +0000
From:   Anton Ivanov <anton.ivanov@...bridgegreys.com>
To:     Richard Weinberger <richard@....at>
Cc:     Song Liu <songliubraving@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        linux-um <linux-um@...ts.infradead.org>,
        Jeff Dike <jdike@...toit.com>,
        kernel-janitors <kernel-janitors@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Wei Yongjun <weiyongjun1@...wei.com>,
        netdev <netdev@...r.kernel.org>, bpf@...r.kernel.org,
        Martin KaFai Lau <kafai@...com>,
        Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [PATCH -next] um: vector: use GFP_ATOMIC under spin lock



On 28/11/2019 08:41, Richard Weinberger wrote:
> ----- Ursprüngliche Mail -----
>> Von: "anton ivanov" <anton.ivanov@...bridgegreys.com>
>> An: "Dan Carpenter" <dan.carpenter@...cle.com>, "Wei Yongjun" <weiyongjun1@...wei.com>
>> CC: "Song Liu" <songliubraving@...com>, "Daniel Borkmann" <daniel@...earbox.net>, "kernel-janitors"
>> <kernel-janitors@...r.kernel.org>, "richard" <richard@....at>, "Jeff Dike" <jdike@...toit.com>, "linux-um"
>> <linux-um@...ts.infradead.org>, "Alexei Starovoitov" <ast@...nel.org>, "netdev" <netdev@...r.kernel.org>,
>> bpf@...r.kernel.org, "Martin KaFai Lau" <kafai@...com>
>> Gesendet: Donnerstag, 28. November 2019 09:18:30
>> Betreff: Re: [PATCH -next] um: vector: use GFP_ATOMIC under spin lock
> 
>> On 28/11/2019 08:06, Dan Carpenter wrote:
>>> On Thu, Nov 28, 2019 at 02:01:47AM +0000, Wei Yongjun wrote:
>>>> A spin lock is taken here so we should use GFP_ATOMIC.
>>>>
>>>> Fixes: 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")
>>>> Signed-off-by: Wei Yongjun <weiyongjun1@...wei.com>
>>>> ---
>>>>    arch/um/drivers/vector_kern.c | 4 ++--
>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
>>>> index 92617e16829e..6ff0065a271d 100644
>>>> --- a/arch/um/drivers/vector_kern.c
>>>> +++ b/arch/um/drivers/vector_kern.c
>>>> @@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device
>>>> *dev,
>>>>    		kfree(vp->bpf->filter);
>>>>    		vp->bpf->filter = NULL;
>>>>    	} else {
>>>> -		vp->bpf = kmalloc(sizeof(struct sock_fprog), GFP_KERNEL);
>>>> +		vp->bpf = kmalloc(sizeof(struct sock_fprog), GFP_ATOMIC);
>>>>    		if (vp->bpf == NULL) {
>>>>    			netdev_err(dev, "failed to allocate memory for firmware\n");
>>>>    			goto flash_fail;
>>>> @@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device
>>>> *dev,
>>>>    	if (request_firmware(&fw, efl->data, &vdevice->pdev.dev))
>>>               ^^^^^^^^^^^^^^^^
>>>
>>> Is it really possible to call request_firmware() while holding a
>>> spin_lock?  I was so sure that read from the disk.
>>
>> Works, I tested the patch quite a few times.
> 
> It works because of the nature of UML ->no  SMP or PREEMPT.
> But better request the firmware before taking the spinlock.
> request_firmware() can block.
> Same for the kmalloc(), just allocate the buffer before and then assign
> the pointer under the lock. That way you don't need GFP_ATOMIC.

Ack.

I will make an incremental on top of the existing patch (as that is 
already in -next

Brgds,

> 
> Thanks,
> //richard
> 
> _______________________________________________
> linux-um mailing list
> linux-um@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-um
> 

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ