lkml.org 
[lkml]   [2022]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 237/287] af_unix: Fix a data-race in unix_dgram_peer_wake_me().
    Date
    From: Kuniyuki Iwashima <kuniyu@amazon.com>

    [ Upstream commit 662a80946ce13633ae90a55379f1346c10f0c432 ]

    unix_dgram_poll() calls unix_dgram_peer_wake_me() without `other`'s
    lock held and check if its receive queue is full. Here we need to
    use unix_recvq_full_lockless() instead of unix_recvq_full(), otherwise
    KCSAN will report a data-race.

    Fixes: 7d267278a9ec ("unix: avoid use-after-free in ep_remove_wait_queue")
    Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
    Link: https://lore.kernel.org/r/20220605232325.11804-1-kuniyu@amazon.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    net/unix/af_unix.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
    index 82279dbd2f62..e79c32942796 100644
    --- a/net/unix/af_unix.c
    +++ b/net/unix/af_unix.c
    @@ -445,7 +445,7 @@ static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other)
    * -ECONNREFUSED. Otherwise, if we haven't queued any skbs
    * to other and its full, we will hang waiting for POLLOUT.
    */
    - if (unix_recvq_full(other) && !sock_flag(other, SOCK_DEAD))
    + if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD))
    return 1;

    if (connected)
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-06-13 14:17    [W:2.329 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site