]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.194/cfg80211-check-vendor-command-doit-pointer-before-us.patch
Drop nfc patches from older trees
[thirdparty/kernel/stable-queue.git] / releases / 4.14.194 / cfg80211-check-vendor-command-doit-pointer-before-us.patch
CommitLineData
a9c34747
SL
1From 615514d8ccafc099b0437e7730c6bf6770fab580 Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Mon, 6 Jul 2020 17:13:53 -0400
4Subject: cfg80211: check vendor command doit pointer before use
5
6From: Julian Squires <julian@cipht.net>
7
8[ Upstream commit 4052d3d2e8f47a15053320bbcbe365d15610437d ]
9
10In the case where a vendor command does not implement doit, and has no
11flags set, doit would not be validated and a NULL pointer dereference
12would occur, for example when invoking the vendor command via iw.
13
14I encountered this while developing new vendor commands. Perhaps in
15practice it is advisable to always implement doit along with dumpit,
16but it seems reasonable to me to always check doit anyway, not just
17when NEED_WDEV.
18
19Signed-off-by: Julian Squires <julian@cipht.net>
20Link: https://lore.kernel.org/r/20200706211353.2366470-1-julian@cipht.net
21Signed-off-by: Johannes Berg <johannes.berg@intel.com>
22Signed-off-by: Sasha Levin <sashal@kernel.org>
23---
24 net/wireless/nl80211.c | 6 +++---
25 1 file changed, 3 insertions(+), 3 deletions(-)
26
27diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
28index d0b75781e6f7a..9be7ee322093b 100644
29--- a/net/wireless/nl80211.c
30+++ b/net/wireless/nl80211.c
31@@ -11859,13 +11859,13 @@ static int nl80211_vendor_cmd(struct sk_buff *skb, struct genl_info *info)
32 if (!wdev_running(wdev))
33 return -ENETDOWN;
34 }
35-
36- if (!vcmd->doit)
37- return -EOPNOTSUPP;
38 } else {
39 wdev = NULL;
40 }
41
42+ if (!vcmd->doit)
43+ return -EOPNOTSUPP;
44+
45 if (info->attrs[NL80211_ATTR_VENDOR_DATA]) {
46 data = nla_data(info->attrs[NL80211_ATTR_VENDOR_DATA]);
47 len = nla_len(info->attrs[NL80211_ATTR_VENDOR_DATA]);
48--
492.25.1
50