* Re: Re: [PATCH] net/packet: fix race condition between fanout_add and __unregister_prot_hook
[not found] <E490CD805F7529488761C40FD9D26EF1299D0CAD@DGGEMA505-MBX.china.huawei.com>
@ 2017-09-19 16:09 ` Willem de Bruijn
2017-09-19 16:12 ` Willem de Bruijn
0 siblings, 1 reply; 2+ messages in thread
From: Willem de Bruijn @ 2017-09-19 16:09 UTC (permalink / raw)
To: Nixiaoming; +Cc: xiyou.wangcong, davem, edumazet, netdev, linux-kernel
On Tue, Sep 19, 2017 at 3:21 AM, Nixiaoming <nixiaoming@huawei.com> wrote:
> On Fri, Sep 15, 2017 at 10:46 AM, Willem de Bruijn
>
> <willemdebruijn.kernel@gmail.com> wrote:
>
>>
>
>> In case of failure we also need to unlink and free match. I
>
>> sent the following:
>
>>
>
>> http://patchwork.ozlabs.org/patch/813945/
>
>
>
> + spin_lock(&po->bind_lock);
>
> + if (po->running &&
>
> + match->type == type &&
>
> match->prot_hook.type == po->prot_hook.type &&
>
> match->prot_hook.dev == po->prot_hook.dev) {
>
> err = -ENOSPC;
>
> @@ -1761,6 +1760,13 @@ static int fanout_add(struct sock *sk, u16 id, u16
> type_flags)
>
> err = 0;
>
> }
>
> }
>
> + spin_unlock(&po->bind_lock);
>
> +
>
> + if (err && !refcount_read(&match->sk_ref)) {
>
> + list_del(&match->list);
>
> + kfree(match);
>
> + }
>
>
>
>
>
> In the function fanout_add add spin_lock to protect po-> running and po->
> fanout,
>
> then whether it should be in the function fanout_release also add spin_lock
> protection ?
po->bind_lock is held when registering and unregistering the
protocol hook. fanout_release does access po->running or
prot_hook.
It is called from packet_release, which does hold the bind_lock
when unregistering the protocol hook.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Re: [PATCH] net/packet: fix race condition between fanout_add and __unregister_prot_hook
2017-09-19 16:09 ` Re: [PATCH] net/packet: fix race condition between fanout_add and __unregister_prot_hook Willem de Bruijn
@ 2017-09-19 16:12 ` Willem de Bruijn
0 siblings, 0 replies; 2+ messages in thread
From: Willem de Bruijn @ 2017-09-19 16:12 UTC (permalink / raw)
To: Nixiaoming; +Cc: xiyou.wangcong, davem, edumazet, netdev, linux-kernel
On Tue, Sep 19, 2017 at 12:09 PM, Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
> On Tue, Sep 19, 2017 at 3:21 AM, Nixiaoming <nixiaoming@huawei.com> wrote:
>> On Fri, Sep 15, 2017 at 10:46 AM, Willem de Bruijn
>>
>> <willemdebruijn.kernel@gmail.com> wrote:
>>
>>>
>>
>>> In case of failure we also need to unlink and free match. I
>>
>>> sent the following:
>>
>>>
>>
>>> http://patchwork.ozlabs.org/patch/813945/
>>
>>
>>
>> + spin_lock(&po->bind_lock);
>>
>> + if (po->running &&
>>
>> + match->type == type &&
>>
>> match->prot_hook.type == po->prot_hook.type &&
>>
>> match->prot_hook.dev == po->prot_hook.dev) {
>>
>> err = -ENOSPC;
>>
>> @@ -1761,6 +1760,13 @@ static int fanout_add(struct sock *sk, u16 id, u16
>> type_flags)
>>
>> err = 0;
>>
>> }
>>
>> }
>>
>> + spin_unlock(&po->bind_lock);
>>
>> +
>>
>> + if (err && !refcount_read(&match->sk_ref)) {
>>
>> + list_del(&match->list);
>>
>> + kfree(match);
>>
>> + }
>>
>>
>>
>>
>>
>> In the function fanout_add add spin_lock to protect po-> running and po->
>> fanout,
>>
>> then whether it should be in the function fanout_release also add spin_lock
>> protection ?
>
> po->bind_lock is held when registering and unregistering the
> protocol hook. fanout_release does access po->running or
> prot_hook.
whoops. does *not* access.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-19 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <E490CD805F7529488761C40FD9D26EF1299D0CAD@DGGEMA505-MBX.china.huawei.com>
2017-09-19 16:09 ` Re: [PATCH] net/packet: fix race condition between fanout_add and __unregister_prot_hook Willem de Bruijn
2017-09-19 16:12 ` Willem de Bruijn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.