Skip to content

Commit

Permalink
nl80211: clear skb cb before passing to netlink
Browse files Browse the repository at this point in the history
commit bd8c78e upstream.

In testmode and vendor command reply/event SKBs we use the
skb cb data to store nl80211 parameters between allocation
and sending. This causes the code for CONFIG_NETLINK_MMAP
to get confused, because it takes ownership of the skb cb
data when the SKB is handed off to netlink, and it doesn't
explicitly clear it.

Clear the skb cb explicitly when we're done and before it
gets passed to netlink to avoid this issue.

Reported-by: Assaf Azulay <assaf.azulay@intel.com>
Reported-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Johannes Berg authored and Greg Kroah-Hartman committed Oct 9, 2014
1 parent 6353c97 commit 7dd3111
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -6568,6 +6568,9 @@ int cfg80211_testmode_reply(struct sk_buff *skb)
void *hdr = ((void **)skb->cb)[1];
struct nlattr *data = ((void **)skb->cb)[2];

/* clear CB data for netlink core to own from now on */
memset(skb->cb, 0, sizeof(skb->cb));

if (WARN_ON(!rdev->testmode_info)) {
kfree_skb(skb);
return -EINVAL;
Expand All @@ -6594,6 +6597,9 @@ void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
void *hdr = ((void **)skb->cb)[1];
struct nlattr *data = ((void **)skb->cb)[2];

/* clear CB data for netlink core to own from now on */
memset(skb->cb, 0, sizeof(skb->cb));

nla_nest_end(skb, data);
genlmsg_end(skb, hdr);
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
Expand Down

0 comments on commit 7dd3111

Please sign in to comment.