Date: Sat, 11 Jun 2016 21:09:06 +0000 From: Raviprakash Darbha <rdarbha@juniper.net> To: "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>, "andre@freebsd.org" <andre@freebsd.org> Cc: Raviprakash Darbha <rdarbha@juniper.net>, Steve Kiernan <stevek@juniper.net> Subject: Re: Double lock issue of unp_link_rwlock in usrreq.c observed Message-ID: <AC28C92C-6EE2-4FAD-B1E7-BB279CF106E5@juniper.net> In-Reply-To: <948AD75B-BF6E-4672-8B50-9CF9E25667EA@juniper.net> References: <948AD75B-BF6E-4672-8B50-9CF9E25667EA@juniper.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Resending the Mail, if anyone has looked at it.
Thanks
RaviPrakash Darbha
rdarbha@juniper.net<mailto:rdarbha@juniper.net>
On May 19, 2016, at 2:06 PM, RaviPrakash Darbha <rdarbha@juniper.net<mailto:rdarbha@juniper.net>> wrote:
Hello Andre
I encountered a double lock issue in unp_connectat function. After looking at the code , I think the unp_link_rwlock is being locked once unp_connectat and once again in unp_detach (called from sofree ). Would like to get your opinion on the issue and the fix. Below is the exact call stack.
UNP_LINK_WLOCK(); <—————————— 1 st call
…..
…..
if (so->so_proto->pr_flags & PR_CONNREQUIRED) {
if (so2->so_options & SO_ACCEPTCONN
CURVNET_SET(so2->so_vnet);
so3 = sonewconn(so2, 0);
// Expanding sonewconn
{
sonewconn
{
……
soalloc
…….
pru_attach
…….
if (!(head->so_options & SO_ACCEPTCONN) &&
((head->so_proto->pr_protocol != IPPROTO_SCTP) ||
(head->so_type != SOCK_SEQPACKET))) {
……….
sofree(so); /* NB: returns ACCEPT_UNLOCK'ed. */
// Expanding sofree
{
…….
pru_detach
// expanding pru_detach
{
// Recursive wlock acquiring.
UNP_LINK_WLOCK() <—————————— 2nd Call
Let me know your thoughts or if you need more information. Thanks !
Thanks
RaviPrakash Darbha
rdarbha@juniper.net<mailto:rdarbha@juniper.net>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AC28C92C-6EE2-4FAD-B1E7-BB279CF106E5>
