From: David Miller <davem@davemloft.net>
To: johannes@sipsolutions.net
Cc: netdev@vger.kernel.org, jeff.layton@primarydata.com,
sedat.dilek@gmail.com, johannes.berg@intel.com
Subject: Re: [PATCH v3 3/3] genetlink: synchronize socket closing and family removal
Date: Fri, 16 Jan 2015 17:20:46 -0500 (EST) [thread overview]
Message-ID: <20150116.172046.1636627616122565664.davem@davemloft.net> (raw)
In-Reply-To: <1421404634-8973-3-git-send-email-johannes@sipsolutions.net>
From: Johannes Berg <johannes@sipsolutions.net>
Date: Fri, 16 Jan 2015 11:37:14 +0100
> From: Johannes Berg <johannes.berg@intel.com>
>
> In addition to the problem Jeff Layton reported, I looked at the code
> and reproduced the same warning by subscribing and removing the genl
> family with a socket still open. This is a fairly tricky race which
> originates in the fact that generic netlink allows the family to go
> away while sockets are still open - unlike regular netlink which has
> a module refcount for every open socket so in general this cannot be
> triggered.
>
> Trying to resolve this issue by the obvious locking isn't possible as
> it will result in deadlocks between unregistration and group unbind
> notification (which incidentally lockdep doesn't find due to the home
> grown locking in the netlink table.)
>
> To really resolve this, introduce a "closing socket" reference counter
> (for generic netlink only, as it's the only affected family) in the
> core netlink code and use that in generic netlink to wait for all the
> sockets that are being closed at the same time as a generic netlink
> family is removed.
>
> This fixes the race that when a socket is closed, it will should call
> the unbind, but if the family is removed at the same time the unbind
> will not find it, leading to the warning. The real problem though is
> that in this case the unbind could actually find a new family that is
> registered to have a multicast group with the same ID, and call its
> mcast_unbind() leading to confusing.
>
> Also remove the warning since it would still trigger, but is now no
> longer a problem.
>
> This also moves the code in af_netlink.c to before unreferencing the
> module to avoid having the same problem in the normal non-genl case.
>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Applied.
next prev parent reply other threads:[~2015-01-16 22:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-16 10:37 [PATCH v3 1/3] genetlink: document parallel_ops Johannes Berg
2015-01-16 10:37 ` [PATCH v3 2/3] genetlink: disallow subscribing to unknown mcast groups Johannes Berg
2015-01-16 22:20 ` David Miller
2015-02-04 11:55 ` Bjørn Mork
2015-02-04 15:36 ` Bjørn Mork
2015-02-04 15:43 ` Johannes Berg
2015-02-04 15:55 ` Bjørn Mork
2015-02-04 16:15 ` Bjørn Mork
2015-02-04 16:16 ` Johannes Berg
2015-01-16 10:37 ` [PATCH v3 3/3] genetlink: synchronize socket closing and family removal Johannes Berg
2015-01-16 22:20 ` David Miller [this message]
2015-01-16 22:19 ` [PATCH v3 1/3] genetlink: document parallel_ops 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=20150116.172046.1636627616122565664.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=jeff.layton@primarydata.com \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=netdev@vger.kernel.org \
--cc=sedat.dilek@gmail.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).