nl80211: Don't verify owner_nlportid on NAN commands

If NAN interface is created with NL80211_ATTR_SOCKET_OWNER, the socket
that is used to create the interface is used for all NAN operations and
reporting NAN events.
However, it turns out that sending commands and receiving events on
the same socket is not possible in a completely race-free way:
If the socket buffer is overflowed by the events, the command response
will not be sent. In that case the caller will block forever on recv.
Using non-blocking socket for commands is more complicated and still
the command response or ack may not be received.
So, keep unicasting NAN events to the interface creator, but allow
using a different socket for commands.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Andrei Otcheretianski 2017-06-26 19:52:30 +03:00 committed by Kalle Valo
parent 123fef3fd4
commit 36a554cec1
2 changed files with 4 additions and 13 deletions

View File

@ -1909,11 +1909,10 @@ enum nl80211_commands {
* that configured the indoor setting, and the indoor operation would be * that configured the indoor setting, and the indoor operation would be
* cleared when the socket is closed. * cleared when the socket is closed.
* If set during NAN interface creation, the interface will be destroyed * If set during NAN interface creation, the interface will be destroyed
* if the socket is closed just like any other interface. Moreover, only * if the socket is closed just like any other interface. Moreover, NAN
* the netlink socket that created the interface will be allowed to add * notifications will be sent in unicast to that socket. Without this
* and remove functions. NAN notifications will be sent in unicast to that * attribute, the notifications will be sent to the %NL80211_MCGRP_NAN
* socket. Without this attribute, any socket can add functions and the * multicast group.
* notifications will be sent to the %NL80211_MCGRP_NAN multicast group.
* If set during %NL80211_CMD_ASSOCIATE or %NL80211_CMD_CONNECT the * If set during %NL80211_CMD_ASSOCIATE or %NL80211_CMD_CONNECT the
* station will deauthenticate when the socket is closed. * station will deauthenticate when the socket is closed.
* *

View File

@ -11206,10 +11206,6 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
if (!info->attrs[NL80211_ATTR_NAN_FUNC]) if (!info->attrs[NL80211_ATTR_NAN_FUNC])
return -EINVAL; return -EINVAL;
if (wdev->owner_nlportid &&
wdev->owner_nlportid != info->snd_portid)
return -ENOTCONN;
err = nla_parse_nested(tb, NL80211_NAN_FUNC_ATTR_MAX, err = nla_parse_nested(tb, NL80211_NAN_FUNC_ATTR_MAX,
info->attrs[NL80211_ATTR_NAN_FUNC], info->attrs[NL80211_ATTR_NAN_FUNC],
nl80211_nan_func_policy, info->extack); nl80211_nan_func_policy, info->extack);
@ -11441,10 +11437,6 @@ static int nl80211_nan_del_func(struct sk_buff *skb,
if (!info->attrs[NL80211_ATTR_COOKIE]) if (!info->attrs[NL80211_ATTR_COOKIE])
return -EINVAL; return -EINVAL;
if (wdev->owner_nlportid &&
wdev->owner_nlportid != info->snd_portid)
return -ENOTCONN;
cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
rdev_del_nan_func(rdev, wdev, cookie); rdev_del_nan_func(rdev, wdev, cookie);