summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian Squires <julian@cipht.net>2020-07-06 17:13:53 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-08-11 15:32:33 +0200
commit8881425b926e6aa4164113401069d03fab52dc39 (patch)
tree140da0234a876204e55f1d87b99ac4b4c23ce8b6
parent937dafe8682044e70821c886d9063869744b3057 (diff)
downloadlinux-stable-8881425b926e6aa4164113401069d03fab52dc39.tar.gz
linux-stable-8881425b926e6aa4164113401069d03fab52dc39.tar.bz2
linux-stable-8881425b926e6aa4164113401069d03fab52dc39.zip
cfg80211: check vendor command doit pointer before use
[ Upstream commit 4052d3d2e8f47a15053320bbcbe365d15610437d ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/wireless/nl80211.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0221849b7218..996b68b48a87 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -12392,13 +12392,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]);