* [PATCH] netlink: don't send NETLINK_URELEASE for unbound sockets
@ 2016-04-07 7:31 Johannes Berg
[not found] ` <1460014298-30293-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2016-04-16 6:30 ` Herbert Xu
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Berg @ 2016-04-07 7:31 UTC (permalink / raw)
To: netdev; +Cc: Dmitry Ivanov, linux-wireless
From: Dmitry Ivanov <dmitrijs.ivanovs@ubnt.com>
All existing users of NETLINK_URELEASE use it to clean up resources that
were previously allocated to a socket via some command. As a result, no
users require getting this notification for unbound sockets.
Sending it for unbound sockets, however, is a problem because any user
(including unprivileged users) can create a socket that uses the same ID
as an existing socket. Binding this new socket will fail, but if the
NETLINK_URELEASE notification is generated for such sockets, the users
thereof will be tricked into thinking the socket that they allocated the
resources for is closed.
In the nl80211 case, this will cause destruction of virtual interfaces
that still belong to an existing hostapd process; this is the case that
Dmitry noticed. In the NFC case, it will cause a poll abort. In the case
of netlink log/queue it will cause them to stop reporting events, as if
NFULNL_CFG_CMD_UNBIND/NFQNL_CFG_CMD_UNBIND had been called.
Fix this problem by checking that the socket is bound before generating
the NETLINK_URELEASE notification.
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Ivanov <dima@ubnt.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/netlink/af_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 215fc08c02ab..330ebd600f25 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -688,7 +688,7 @@ static int netlink_release(struct socket *sock)
skb_queue_purge(&sk->sk_write_queue);
- if (nlk->portid) {
+ if (nlk->portid && nlk->bound) {
struct netlink_notify n = {
.net = sock_net(sk),
.protocol = sk->sk_protocol,
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <1460014298-30293-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>]
* Re: [PATCH] netlink: don't send NETLINK_URELEASE for unbound sockets
[not found] ` <1460014298-30293-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
@ 2016-04-11 3:33 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-04-11 3:33 UTC (permalink / raw)
To: johannes-cdvu00un1VgdHxzADdlk8Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, dmitrijs.ivanovs-NO1NBkfNQUg,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
From: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
Date: Thu, 7 Apr 2016 09:31:38 +0200
> From: Dmitry Ivanov <dmitrijs.ivanovs-NO1NBkfNQUg@public.gmane.org>
>
> All existing users of NETLINK_URELEASE use it to clean up resources that
> were previously allocated to a socket via some command. As a result, no
> users require getting this notification for unbound sockets.
>
> Sending it for unbound sockets, however, is a problem because any user
> (including unprivileged users) can create a socket that uses the same ID
> as an existing socket. Binding this new socket will fail, but if the
> NETLINK_URELEASE notification is generated for such sockets, the users
> thereof will be tricked into thinking the socket that they allocated the
> resources for is closed.
>
> In the nl80211 case, this will cause destruction of virtual interfaces
> that still belong to an existing hostapd process; this is the case that
> Dmitry noticed. In the NFC case, it will cause a poll abort. In the case
> of netlink log/queue it will cause them to stop reporting events, as if
> NFULNL_CFG_CMD_UNBIND/NFQNL_CFG_CMD_UNBIND had been called.
>
> Fix this problem by checking that the socket is bound before generating
> the NETLINK_URELEASE notification.
>
> Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Signed-off-by: Dmitry Ivanov <dima-NO1NBkfNQUg@public.gmane.org>
> Signed-off-by: Johannes Berg <johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Applied and queued up for -stable, thanks everyone.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] netlink: don't send NETLINK_URELEASE for unbound sockets
2016-04-07 7:31 [PATCH] netlink: don't send NETLINK_URELEASE for unbound sockets Johannes Berg
[not found] ` <1460014298-30293-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
@ 2016-04-16 6:30 ` Herbert Xu
[not found] ` <20160416063040.GA6380-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2016-04-16 6:30 UTC (permalink / raw)
To: Johannes Berg; +Cc: netdev, dmitrijs.ivanovs, linux-wireless
Johannes Berg <johannes@sipsolutions.net> wrote:
>
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index 215fc08c02ab..330ebd600f25 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -688,7 +688,7 @@ static int netlink_release(struct socket *sock)
>
> skb_queue_purge(&sk->sk_write_queue);
>
> - if (nlk->portid) {
> + if (nlk->portid && nlk->bound) {
Any reason why we're still testing portid at all? Isn't testing
bound enough?
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-16 21:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-07 7:31 [PATCH] netlink: don't send NETLINK_URELEASE for unbound sockets Johannes Berg
[not found] ` <1460014298-30293-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2016-04-11 3:33 ` David Miller
2016-04-16 6:30 ` Herbert Xu
[not found] ` <20160416063040.GA6380-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2016-04-16 21:42 ` Johannes Berg
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).