mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vlad Efanov <vefanov@ispras.ru>
To: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	David Ahern <dsahern@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH] udp6: Fix race condition in udp6_sendmsg & connect
Date: Fri, 26 May 2023 19:41:07 +0300	[thread overview]
Message-ID: <d3fccbd0-c92e-9aff-8c32-48c1171746c3@ispras.ru> (raw)
In-Reply-To: <CANn89iLGOVwW-KHBuJ94E+QoVARWw5EBKyfh0mPkOT+5ws31Fw@mail.gmail.com>

sk_dst_set() is called by sk_setup_caps().

sk_dst_set() replaces dst in socket using xchg() call and we still have 
two tasks use one socket but expect different dst in sk_dst_cache.


__sk_dst_set() is rcu protected, but it checks for socket lock.


static inline void
__sk_dst_set(struct sock *sk, struct dst_entry *dst)
{
     struct dst_entry *old_dst;

     sk_tx_queue_clear(sk);
     sk->sk_dst_pending_confirm = 0;
     old_dst = rcu_dereference_protected(sk->sk_dst_cache,
                         lockdep_sock_is_held(sk));
     rcu_assign_pointer(sk->sk_dst_cache, dst);
     dst_release(old_dst);
}


Best regards.

Vlad.


On 26.05.2023 19:00, Eric Dumazet wrote:
> On Fri, May 26, 2023 at 5:58 PM Ефанов Владислав Александрович
> <vefanov@ispras.ru> wrote:
>> Paolo,
>>
>>
>> I don't think that we can just move sk_dst_set() call.
>>
>> I think we can destroy dst of sendmsg task in this case.
>>
> dst are RCU protected, it should be easy to make sure we respect all the rules.

  reply	other threads:[~2023-05-26 16:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 15:08 Vladislav Efanov
2023-05-26 15:29 ` Eric Dumazet
2023-05-26 15:49   ` Ефанов Владислав Александрович
2023-05-26 16:09   ` Vlad Efanov
2023-05-26 16:46     ` Eric Dumazet
2023-05-26 16:57       ` Vlad Efanov
2023-05-26 15:33 ` Paolo Abeni
2023-05-26 15:58   ` Ефанов Владислав Александрович
2023-05-26 16:00     ` Eric Dumazet
2023-05-26 16:41       ` Vlad Efanov [this message]
2023-05-26 16:47         ` Eric Dumazet
2023-05-26 17:00           ` Vlad Efanov
2023-05-26 18:13     ` Paolo Abeni
2023-05-29 14:13       ` Vlad Efanov
2023-05-30 11:39   ` [PATCH v2] " Vladislav Efanov
2023-05-31  9:40     ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3fccbd0-c92e-9aff-8c32-48c1171746c3@ispras.ru \
    --to=vefanov@ispras.ru \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®