MPTCP Linux Development
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Mat Martineau <mathew.j.martineau@linux.intel.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-net v3 6/6] mptcp: fix race on unaccepted mptcp sockets
Date: Mon, 20 Jun 2022 12:47:52 +0200	[thread overview]
Message-ID: <ba1862a2456f92b8a83ec00bec65a8208e8d44a4.camel@redhat.com> (raw)
In-Reply-To: <54f723756f4b4da8827649b6c2f11187e93bf050.camel@redhat.com>

On Mon, 2022-06-20 at 12:15 +0200, Paolo Abeni wrote:
> On Fri, 2022-06-17 at 17:51 -0700, Mat Martineau wrote:
> > On Fri, 17 Jun 2022, Paolo Abeni wrote:
> > > diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> > > index 1e182301e58b..db83db1b3c4c 100644
> > > --- a/net/mptcp/subflow.c
> > > +++ b/net/mptcp/subflow.c
> > > @@ -1723,6 +1723,56 @@ static void subflow_state_change(struct sock *sk)
> > > 	}
> > > }
> > > 
> > > +void mptcp_subflow_queue_clean(struct sock *listener_ssk)
> > > +{
> > > +	struct request_sock_queue *queue = &inet_csk(listener_ssk)->icsk_accept_queue;
> > > +	struct mptcp_sock *msk, *next, *head = NULL;
> > > +	struct request_sock *req;
> > > +
> > > +	/* build a list of all unaccepted mptcp sockets */
> > > +	spin_lock_bh(&queue->rskq_lock);
> > > +	for (req = queue->rskq_accept_head; req; req = req->dl_next) {
> > > +		struct mptcp_subflow_context *subflow;
> > > +		struct sock *ssk = req->sk;
> > > +		struct mptcp_sock *msk;
> > > +
> > > +		if (!sk_is_mptcp(ssk))
> > > +			continue;
> > > +
> > > +		subflow = mptcp_subflow_ctx(ssk);
> > > +		if (!subflow || !subflow->conn)
> > > +			continue;
> > > +
> > > +		/* skip if already in list */
> > > +		msk = mptcp_sk(subflow->conn);
> > > +		if (msk->dl_next || msk == head)
> > > +			continue;
> > > +
> > > +		msk->dl_next = head;
> > 
> > Why is it ok to read/modify msk->dl_next without the msk locked here, but 
> > the msk lock is needed below?
> 
> the dl_next field is protected from the listener socket lock. Such lock
> is held both here and below, see the caller of this function.
> 

I see the above is not very clear; I mean: this whole function runs
under the listener _msk_ socket lock. The 'dl_next' list is under such
protection.

/P


  reply	other threads:[~2022-06-20 10:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 10:05 [PATCH mptcp-net v3 0/6] mptcp: mp_fail related fixes Paolo Abeni
2022-06-17 10:05 ` [PATCH mptcp-net v3 1/6] mptcp: fix error mibs accounting Paolo Abeni
2022-06-17 10:05 ` [PATCH mptcp-net v3 2/6] mptcp: introduce MAPPING_BAD_CSUM Paolo Abeni
2022-06-17 23:13   ` Mat Martineau
2022-06-20  9:24     ` Paolo Abeni
2022-06-17 10:05 ` [PATCH mptcp-net v3 3/6] Squash-to: "mptcp: invoke MP_FAIL response when needed" Paolo Abeni
2022-06-17 14:01   ` Paolo Abeni
2022-06-17 23:06     ` Mat Martineau
2022-06-17 10:05 ` [PATCH mptcp-net v3 4/6] mptcp: fix shutdown vs fallback race Paolo Abeni
2022-06-17 10:05 ` [PATCH mptcp-net v3 5/6] mptcp: consistent map handling on failure Paolo Abeni
2022-06-17 10:05 ` [PATCH mptcp-net v3 6/6] mptcp: fix race on unaccepted mptcp sockets Paolo Abeni
2022-06-17 11:57   ` mptcp: fix race on unaccepted mptcp sockets: Tests Results MPTCP CI
2022-06-18  0:51   ` [PATCH mptcp-net v3 6/6] mptcp: fix race on unaccepted mptcp sockets Mat Martineau
2022-06-20 10:15     ` Paolo Abeni
2022-06-20 10:47       ` Paolo Abeni [this message]
2022-06-17 23:05 ` [PATCH mptcp-net v3 0/6] mptcp: mp_fail related fixes Mat Martineau

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=ba1862a2456f92b8a83ec00bec65a8208e8d44a4.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=mptcp@lists.linux.dev \
    /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