From: Vlad Yasevich <vyasevich@gmail.com>
To: Daniel Borkmann <dborkman@redhat.com>
Cc: davem@davemloft.net, linux-sctp@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3] sctp: sctp_close: fix release of bindings for deferred call_rcu's
Date: Fri, 01 Feb 2013 09:55:10 -0500 [thread overview]
Message-ID: <510BD74E.3010409@gmail.com> (raw)
In-Reply-To: <1359729463-11833-1-git-send-email-dborkman@redhat.com>
On 02/01/2013 09:37 AM, Daniel Borkmann wrote:
>
> The underlying problem is that sctp_endpoint_destroy() hasn't been
> triggered yet while the next bind attempt is being done. It will be
> triggered eventually (but too late) by sctp_transport_destroy_rcu()
> after one RCU grace period:
>
> sctp_transport_destroy()
> sctp_transport_destroy_rcu() ----.
> sctp_association_put() [*] <--+--> sctp_packet_free()
> sctp_association_destroy() [...]
> sctp_endpoint_put() skb->destructor
> sctp_endpoint_destroy() sctp_wfree()
> sctp_bind_addr_free() sctp_association_put() [*]
>
> Thus, we move out the condition with sctp_association_put() as well as
> the sctp_packet_free() invocation and the issue can be solved. We also
> better free the SCTP chunks first before putting the ref of the association.
>
> With this patch, the example above (which simulates a similar scenario
> as in the implementation of this test case) and therefore also the test
> suite run successfully through. Tested by myself.
>
> Cc: Vlad Yasevich <vyasevich@gmail.com>
> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
-vlad
> ---
> net/sctp/transport.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/net/sctp/transport.c b/net/sctp/transport.c
> index 4e45bb6..ca5331c 100644
> --- a/net/sctp/transport.c
> +++ b/net/sctp/transport.c
> @@ -168,10 +168,6 @@ static void sctp_transport_destroy_rcu(struct rcu_head *head)
> struct sctp_transport *transport;
>
> transport = container_of(head, struct sctp_transport, rcu);
> - if (transport->asoc)
> - sctp_association_put(transport->asoc);
> -
> - sctp_packet_free(&transport->packet);
>
> dst_release(transport->dst);
> kfree(transport);
> @@ -186,6 +182,11 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
> SCTP_ASSERT(transport->dead, "Transport is not dead", return);
>
> call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
> +
> + sctp_packet_free(&transport->packet);
> +
> + if (transport->asoc)
> + sctp_association_put(transport->asoc);
> }
>
> /* Start T3_rtx timer if it is not already running and update the heartbeat
>
next prev parent reply other threads:[~2013-02-01 14:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-01 14:37 [PATCH net-next v3] sctp: sctp_close: fix release of bindings for deferred call_rcu's Daniel Borkmann
2013-02-01 14:55 ` Vlad Yasevich [this message]
2013-02-04 12:10 ` Neil Horman
2013-02-04 18:23 ` 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=510BD74E.3010409@gmail.com \
--to=vyasevich@gmail.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=linux-sctp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).