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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220315105246.77468-1-kuniyu@amazon.co.jp>
Date:   Tue, 15 Mar 2022 19:52:46 +0900
From:   Kuniyuki Iwashima <kuniyu@...zon.co.jp>
To:     <kuniyu@...zon.co.jp>
CC:     <davem@...emloft.net>, <eric.dumazet@...il.com>, <kuba@...nel.org>,
        <kuni1840@...il.com>, <netdev@...r.kernel.org>,
        <rao.shoaib@...cle.com>
Subject: Re: [PATCH net] af_unix: Support POLLPRI for OOB.

From:   Kuniyuki Iwashima <kuniyu@...zon.co.jp>
Date:   Tue, 15 Mar 2022 14:30:40 +0900
> From:   Kuniyuki Iwashima <kuniyu@...zon.co.jp>
> Date:   Tue, 15 Mar 2022 09:45:03 +0900
>> From:   Eric Dumazet <eric.dumazet@...il.com>
>> Date:   Mon, 14 Mar 2022 17:26:54 -0700
>>> On 3/14/22 11:10, Shoaib Rao wrote:
>>>>
>>>> On 3/14/22 10:42, Eric Dumazet wrote:
>>>>>
>>>>> On 3/13/22 22:21, Kuniyuki Iwashima wrote:
>>>>>> The commit 314001f0bf92 ("af_unix: Add OOB support") introduced OOB for
>>>>>> AF_UNIX, but it lacks some changes for POLLPRI.  Let's add the missing
>>>>>> piece.
>>>>>>
>>>>>> In the selftest, normal datagrams are sent followed by OOB data, so 
>>>>>> this
>>>>>> commit replaces `POLLIN | POLLPRI` with just `POLLPRI` in the first 
>>>>>> test
>>>>>> case.
>>>>>>
>>>>>> Fixes: 314001f0bf92 ("af_unix: Add OOB support")
>>>>>> Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.co.jp>
>>>>>> ---
>>>>>>   net/unix/af_unix.c                                  | 2 ++
>>>>>>   tools/testing/selftests/net/af_unix/test_unix_oob.c | 6 +++---
>>>>>>   2 files changed, 5 insertions(+), 3 deletions(-)
>>>>>>
>>>>>> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
>>>>>> index c19569819866..711d21b1c3e1 100644
>>>>>> --- a/net/unix/af_unix.c
>>>>>> +++ b/net/unix/af_unix.c
>>>>>> @@ -3139,6 +3139,8 @@ static __poll_t unix_poll(struct file *file, 
>>>>>> struct socket *sock, poll_table *wa
>>>>>>           mask |= EPOLLIN | EPOLLRDNORM;
>>>>>>       if (sk_is_readable(sk))
>>>>>>           mask |= EPOLLIN | EPOLLRDNORM;
>>>>>> +    if (unix_sk(sk)->oob_skb)
>>>>>> +        mask |= EPOLLPRI;
>>>>>
>>>>>
>>>>> This adds another data-race, maybe add something to avoid another 
>>>>> syzbot report ?
>>>>
>>>> It's not obvious to me how there would be a race as it is just a check.
>>>>
>>> 
>>> KCSAN will detect that whenever unix_poll() reads oob_skb,
>>> 
>>> its value can be changed by another cpu.
>>> 
>>> 
>>> unix_poll() runs without holding a lock.
>> 
>> Thanks for pointing out!
>> So, READ_ONCE() is necessary here, right?
>> oob_skb is written under the lock, so I think there is no paired
>> WRITE_ONCE(), but is it ok?

I have misunderstood this, the lock has nothing to do with WRITE_ONCE()
this time.  The write of oob_skb can be teared by GCC, which leads to a
data race at the read side even with READ_ONCE(), so the paired one is
needed.

I will respin v3 with READ_ONCE() and WRITE_ONCE().


> 
> I've tested the prog below and KCSAN repoted the race.
> Also, READ_ONCE() suppressed it.
> 
> Thank you Eric!
> I'll post v2 with READ_ONCE().

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ