From: Marcelo Ricardo Leitner <marcelo.leitner@gmail•com>
To: Xin Long <lucien.xin@gmail•com>
Cc: network dev <netdev@vger•kernel.org>,
linux-sctp@vger•kernel.org, Vlad Yasevich <vyasevich@gmail•com>,
daniel@iogearbox•net, davem@davemloft•net
Subject: Re: [PATCH net 2/3] sctp: hold transport before we access t->asoc in sctp proc
Date: Thu, 21 Jan 2016 15:53:47 -0200 [thread overview]
Message-ID: <20160121175347.GE3452@mrl.redhat.com> (raw)
In-Reply-To: <4357f1f3ad90ffec1481a265d8ca198d75e25d07.1453398443.git.lucien.xin@gmail.com>
On Fri, Jan 22, 2016 at 01:49:08AM +0800, Xin Long wrote:
> Previously, before rhashtable, /proc assoc listing was done by
> read-locking the entire hash entry and dumping all assocs at once, so we
> were sure that the assoc wasn't freed because it wouldn't be possible to
> remove it from the hash meanwhile.
>
> Now we use rhashtable to list transports, and dump entries one by one.
> That is, now we have to check if the assoc is still a good one, as the
> transport we got may be being freed.
>
> Signed-off-by: Xin Long <lucien.xin@gmail•com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail•com>
> ---
> net/sctp/proc.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/net/sctp/proc.c b/net/sctp/proc.c
> index 684c5b3..c74a810 100644
> --- a/net/sctp/proc.c
> +++ b/net/sctp/proc.c
> @@ -380,6 +380,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
> }
>
> transport = (struct sctp_transport *)v;
> + if (!sctp_transport_hold(transport))
> + return 0;
> assoc = transport->asoc;
> epb = &assoc->base;
> sk = epb->sk;
> @@ -412,6 +414,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
> sk->sk_rcvbuf);
> seq_printf(seq, "\n");
>
> + sctp_transport_put(transport);
> +
> return 0;
> }
>
> @@ -489,6 +493,8 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
> }
>
> tsp = (struct sctp_transport *)v;
> + if (!sctp_transport_hold(tsp))
> + return 0;
> assoc = tsp->asoc;
>
> list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list,
> @@ -544,6 +550,8 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
> seq_printf(seq, "\n");
> }
>
> + sctp_transport_put(tsp);
> +
> return 0;
> }
>
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger•kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2016-01-21 17:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-21 17:49 [PATCH net 0/3] fix the transport dead race check by using atomic_add_unless on refcnt Xin Long
2016-01-21 17:49 ` [PATCH net 1/3] sctp: " Xin Long
2016-01-21 17:53 ` Marcelo Ricardo Leitner
2016-01-22 16:50 ` Vlad Yasevich
2016-01-22 17:18 ` Marcelo Ricardo Leitner
2016-01-22 18:54 ` Vlad Yasevich
2016-01-25 18:44 ` David Miller
2016-01-21 17:49 ` [PATCH net 2/3] sctp: hold transport before we access t->asoc in sctp proc Xin Long
2016-01-21 17:53 ` Marcelo Ricardo Leitner [this message]
2016-01-21 19:27 ` Eric Dumazet
2016-01-21 19:37 ` Marcelo Ricardo Leitner
2016-01-21 19:57 ` Eric Dumazet
2016-01-21 20:08 ` Marcelo Ricardo Leitner
2016-01-21 17:49 ` [PATCH net 3/3] sctp: remove the dead field of sctp_transport Xin Long
2016-01-21 17:54 ` Marcelo Ricardo Leitner
2016-01-21 17:58 ` [PATCH net 0/3] fix the transport dead race check by using atomic_add_unless on refcnt Xin Long
2016-01-28 23:59 ` David Miller
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=20160121175347.GE3452@mrl.redhat.com \
--to=marcelo.leitner@gmail$(echo .)com \
--cc=daniel@iogearbox$(echo .)net \
--cc=davem@davemloft$(echo .)net \
--cc=linux-sctp@vger$(echo .)kernel.org \
--cc=lucien.xin@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=vyasevich@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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