Skip to content

Commit

Permalink
cfg80211: check vendor command doit pointer before use
Browse files Browse the repository at this point in the history
In the case where a vendor command does not implement doit, and has no
flags set, doit would not be validated and a NULL pointer dereference
would occur, for example when invoking the vendor command via iw.

I encountered this while developing new vendor commands.  Perhaps in
practice it is advisable to always implement doit along with dumpit,
but it seems reasonable to me to always check doit anyway, not just
when NEED_WDEV.

Signed-off-by: Julian Squires <julian@cipht.net>
Link: https://lore.kernel.org/r/20200706211353.2366470-1-julian@cipht.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
tokenrove authored and jmberg-intel committed Jul 30, 2020
1 parent 5e43540 commit 4052d3d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -13266,13 +13266,13 @@ static int nl80211_vendor_cmd(struct sk_buff *skb, struct genl_info *info)
if (!wdev_running(wdev))
return -ENETDOWN;
}

if (!vcmd->doit)
return -EOPNOTSUPP;
} else {
wdev = NULL;
}

if (!vcmd->doit)
return -EOPNOTSUPP;

if (info->attrs[NL80211_ATTR_VENDOR_DATA]) {
data = nla_data(info->attrs[NL80211_ATTR_VENDOR_DATA]);
len = nla_len(info->attrs[NL80211_ATTR_VENDOR_DATA]);
Expand Down

0 comments on commit 4052d3d

Please sign in to comment.