From: David Miller <davem@davemloft.net>
To: jon.maloy@ericsson.com
Cc: netdev@vger.kernel.org,
mohan.krishna.ghanta.krishnamurthy@ericsson.com,
tung.q.nguyen@dektech.com.au, hoang.h.le@dektech.com.au,
canh.d.luu@dektech.com.au, ying.xue@windriver.com,
tipc-discussion@lists.sourceforge.net
Subject: Re: [net-next 1/1] tipc: fix race condition at topology server receive
Date: Tue, 16 Jan 2018 14:42:54 -0500 (EST) [thread overview]
Message-ID: <20180116.144254.1952039888762980221.davem@davemloft.net> (raw)
In-Reply-To: <1516035388-18818-1-git-send-email-jon.maloy@ericsson.com>
From: Jon Maloy <jon.maloy@ericsson.com>
Date: Mon, 15 Jan 2018 17:56:28 +0100
> We have identified a race condition during reception of socket
> events and messages in the topology server.
>
> - The function tipc_close_conn() is releasing the corresponding
> struct tipc_subscriber instance without considering that there
> may still be items in the receive work queue. When those are
> scheduled, in the function tipc_receive_from_work(), they are
> using the subscriber pointer stored in struct tipc_conn, without
> first checking if this is valid or not. This will sometimes
> lead to crashes, as the next call of tipc_conn_recvmsg() will
> access the now deleted item.
> We fix this by making the usage of this pointer conditional on
> whether the connection is active or not. I.e., we check the condition
> test_bit(CF_CONNECTED) before making the call tipc_conn_recvmsg().
>
> - Since the two functions may be running on different cores, the
> condition test described above is not enough. tipc_close_conn()
> may come in between and delete the subscriber item after the condition
> test is done, but before tipc_conn_recv_msg() is finished. This
> happens less frequently than the problem described above, but leads
> to the same symptoms.
>
> We fix this by using the existing sk_callback_lock for mutual
> exclusion in the two functions. In addition, we have to move
> a call to tipc_conn_terminate() outside the mentioned lock to
> avoid deadlock.
>
> Acked-by: Ying Xue <ying.xue@windriver.com>
> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Applied, thanks Jon.
prev parent reply other threads:[~2018-01-16 19:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 16:56 [net-next 1/1] tipc: fix race condition at topology server receive Jon Maloy
2018-01-16 19:42 ` David Miller [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=20180116.144254.1952039888762980221.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=canh.d.luu@dektech.com.au \
--cc=hoang.h.le@dektech.com.au \
--cc=jon.maloy@ericsson.com \
--cc=mohan.krishna.ghanta.krishnamurthy@ericsson.com \
--cc=netdev@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.q.nguyen@dektech.com.au \
--cc=ying.xue@windriver.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).