Re: [PATCH] skbuff: fix a data race in skb_queue_len()

From: Eric Dumazet
Date: Mon Feb 03 2020 - 15:28:57 EST




On 2/3/20 12:19 PM, Qian Cai wrote:
>
>
>> On Feb 3, 2020, at 2:42 PM, Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
>>
>> We do not want to add READ_ONCE() for all uses of skb_queue_len()
>>
>> This could hide some real bugs, and could generate slightly less
>> efficient code in the cases we have the lock held.
>
> Good point. I should have thought about that. How about introducing 2 new helpers.
>
> skb_queue_len_once()
> unix_recvq_full_once()
>
> which will have a READ_ONCE() there, and then unix_dgram_sendmsg() could use that instead?
>

We added recently skb_queue_empty_lockless() helper, to use in these contexts.

The fact that we use READ_ONCE() is more of an implementation detail I think.

Also, addressing load-stearing issues without making sure the write side
is using WRITE_ONCE() might be not enough (even if KCSAN warnings disappear)