netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Sitnicki <jakub@cloudflare.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, kernel-team@cloudflare.com,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Tom Parkin <tparkin@katalix.com>,
	Haowei Yan <g1042620637@gmail.com>
Subject: Re: [PATCH net v3] l2tp: Serialize access to sk_user_data with sk_callback_lock
Date: Fri, 26 Aug 2022 10:32:22 +0200	[thread overview]
Message-ID: <87ilmf9zha.fsf@cloudflare.com> (raw)
In-Reply-To: <97b1225e848caf6034aa68ef8bc6ded3823a8149.camel@redhat.com>

On Thu, Aug 25, 2022 at 12:23 PM +02, Paolo Abeni wrote:
> hello,
>
> On Tue, 2022-08-23 at 12:14 +0200, Jakub Sitnicki wrote:
>> sk->sk_user_data has multiple users, which are not compatible with each
>> other. Writers must synchronize by grabbing the sk->sk_callback_lock.
>> 
>> l2tp currently fails to grab the lock when modifying the underlying tunnel
>> socket. Fix it by adding appropriate locking.
>> 
>> We don't to grab the lock when l2tp clears sk_user_data, because it happens
>> only in sk->sk_destruct, when the sock is going away.
>
> l2tp can additionally clears sk_user_data in sk->sk_prot->close() via 
> udp_lib_close() -> sk_common_release() -> sk->sk_prot->destroy() -> 
> udp_destroy_sock() -> up->encap_destroy() -> l2tp_udp_encap_destroy().
>
> That still happens at socket closing time, but when network has still
> access to the sock itself. It should be safe as the other sk_user_data
> users touch it only via fd, but perhaps a 'better safe the sorry'
> approach could be relevant there?

Fair point. Let me add that.

      reply	other threads:[~2022-08-26  8:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 10:14 [PATCH net v3] l2tp: Serialize access to sk_user_data with sk_callback_lock Jakub Sitnicki
2022-08-25 10:23 ` Paolo Abeni
2022-08-26  8:32   ` Jakub Sitnicki [this message]

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=87ilmf9zha.fsf@cloudflare.com \
    --to=jakub@cloudflare.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=g1042620637@gmail.com \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tparkin@katalix.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;
as well as URLs for NNTP newsgroup(s).