Revert "genetlink: hold RCU in genlmsg_mcast()"
This reverts commit 0d2bd44bfe which is
commit 56440d7ec28d60f8da3bfa09062b3368ff9b16db upstream.
It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.
Bug: 161946584
Change-Id: Ie8c829833eef0ab6b68677f3da08620e894787a0
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
9d6ed89ef0
commit
bc1dcc543b
5 changed files with 25 additions and 20 deletions
|
|
@ -1788,7 +1788,7 @@ static int tcmu_netlink_event_send(struct tcmu_dev *udev,
|
|||
}
|
||||
|
||||
ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0,
|
||||
TCMU_MCGRP_CONFIG);
|
||||
TCMU_MCGRP_CONFIG, GFP_KERNEL);
|
||||
|
||||
/* Wait during an add as the listener may not be up yet */
|
||||
if (ret == 0 ||
|
||||
|
|
|
|||
|
|
@ -296,12 +296,13 @@ static inline int genlmsg_multicast(const struct genl_family *family,
|
|||
* @skb: netlink message as socket buffer
|
||||
* @portid: own netlink portid to avoid sending to yourself
|
||||
* @group: offset of multicast group in groups array
|
||||
* @flags: allocation flags
|
||||
*
|
||||
* This function must hold the RTNL or rcu_read_lock().
|
||||
*/
|
||||
int genlmsg_multicast_allns(const struct genl_family *family,
|
||||
struct sk_buff *skb, u32 portid,
|
||||
unsigned int group);
|
||||
unsigned int group, gfp_t flags);
|
||||
|
||||
/**
|
||||
* genlmsg_unicast - unicast a netlink message
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ static int l2tp_tunnel_notify(struct genl_family *family,
|
|||
NLM_F_ACK, tunnel, cmd);
|
||||
|
||||
if (ret >= 0) {
|
||||
ret = genlmsg_multicast_allns(family, msg, 0, 0);
|
||||
ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC);
|
||||
/* We don't care if no one is listening */
|
||||
if (ret == -ESRCH)
|
||||
ret = 0;
|
||||
|
|
@ -145,7 +145,7 @@ static int l2tp_session_notify(struct genl_family *family,
|
|||
NLM_F_ACK, session, cmd);
|
||||
|
||||
if (ret >= 0) {
|
||||
ret = genlmsg_multicast_allns(family, msg, 0, 0);
|
||||
ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC);
|
||||
/* We don't care if no one is listening */
|
||||
if (ret == -ESRCH)
|
||||
ret = 0;
|
||||
|
|
|
|||
|
|
@ -949,11 +949,15 @@ static int genl_ctrl_event(int event, const struct genl_family *family,
|
|||
if (IS_ERR(msg))
|
||||
return PTR_ERR(msg);
|
||||
|
||||
if (!family->netnsok)
|
||||
if (!family->netnsok) {
|
||||
genlmsg_multicast_netns(&genl_ctrl, &init_net, msg, 0,
|
||||
0, GFP_KERNEL);
|
||||
else
|
||||
genlmsg_multicast_allns(&genl_ctrl, msg, 0, 0);
|
||||
} else {
|
||||
rcu_read_lock();
|
||||
genlmsg_multicast_allns(&genl_ctrl, msg, 0,
|
||||
0, GFP_ATOMIC);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1054,23 +1058,23 @@ struct nlattr **genl_family_attrbuf(const struct genl_family *family)
|
|||
}
|
||||
EXPORT_SYMBOL(genl_family_attrbuf);
|
||||
|
||||
static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group)
|
||||
static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
|
||||
gfp_t flags)
|
||||
{
|
||||
struct sk_buff *tmp;
|
||||
struct net *net, *prev = NULL;
|
||||
bool delivered = false;
|
||||
int err;
|
||||
|
||||
rcu_read_lock();
|
||||
for_each_net_rcu(net) {
|
||||
if (prev) {
|
||||
tmp = skb_clone(skb, GFP_ATOMIC);
|
||||
tmp = skb_clone(skb, flags);
|
||||
if (!tmp) {
|
||||
err = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
err = nlmsg_multicast(prev->genl_sock, tmp,
|
||||
portid, group, GFP_ATOMIC);
|
||||
portid, group, flags);
|
||||
if (!err)
|
||||
delivered = true;
|
||||
else if (err != -ESRCH)
|
||||
|
|
@ -1079,30 +1083,26 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group)
|
|||
|
||||
prev = net;
|
||||
}
|
||||
err = nlmsg_multicast(prev->genl_sock, skb, portid, group, GFP_ATOMIC);
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
err = nlmsg_multicast(prev->genl_sock, skb, portid, group, flags);
|
||||
if (!err)
|
||||
delivered = true;
|
||||
else if (err != -ESRCH)
|
||||
return err;
|
||||
return delivered ? 0 : -ESRCH;
|
||||
error:
|
||||
rcu_read_unlock();
|
||||
|
||||
kfree_skb(skb);
|
||||
return err;
|
||||
}
|
||||
|
||||
int genlmsg_multicast_allns(const struct genl_family *family,
|
||||
struct sk_buff *skb, u32 portid,
|
||||
unsigned int group)
|
||||
unsigned int group, gfp_t flags)
|
||||
{
|
||||
if (WARN_ON_ONCE(group >= family->n_mcgrps))
|
||||
return -EINVAL;
|
||||
group = family->mcgrp_offset + group;
|
||||
return genlmsg_mcast(skb, portid, group);
|
||||
return genlmsg_mcast(skb, portid, group, flags);
|
||||
}
|
||||
EXPORT_SYMBOL(genlmsg_multicast_allns);
|
||||
|
||||
|
|
|
|||
|
|
@ -15407,8 +15407,10 @@ void nl80211_common_reg_change_event(enum nl80211_commands cmd_id,
|
|||
|
||||
genlmsg_end(msg, hdr);
|
||||
|
||||
rcu_read_lock();
|
||||
genlmsg_multicast_allns(&nl80211_fam, msg, 0,
|
||||
NL80211_MCGRP_REGULATORY);
|
||||
NL80211_MCGRP_REGULATORY, GFP_ATOMIC);
|
||||
rcu_read_unlock();
|
||||
|
||||
return;
|
||||
|
||||
|
|
@ -15907,8 +15909,10 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy,
|
|||
|
||||
genlmsg_end(msg, hdr);
|
||||
|
||||
rcu_read_lock();
|
||||
genlmsg_multicast_allns(&nl80211_fam, msg, 0,
|
||||
NL80211_MCGRP_REGULATORY);
|
||||
NL80211_MCGRP_REGULATORY, GFP_ATOMIC);
|
||||
rcu_read_unlock();
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue