Skip to contentSkip to conversation

wifi: cfg80211: release locks on error in cfg80211_wext_siwgenie()

PATCH In review Wentao Guan 2 participants 4 messages Oct 12 – Oct 13 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: cfg80211: release locks on error in cfg80211_wext_siwgenie()

This error path returns while wdev_lock() is still held, so one malformed IE request can permanently block later operations on this wiphy. Route the error through out to release the lock.

Fixes 8b921a899346 ("wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()")
---
 net/wireless/wext-sme.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/wireless/wext-sme.c +4 -2
index be121fa36c514..ba6d8827f64b3 100644
@@ -352,8 +352,10 @@ int cfg80211_wext_siwgenie(struct net_device *dev,
 			/* nothing */
 		}
 
-		if (!for_each_element_completed(elem, extra, ie_len))
-			return -EINVAL;
+		if (!for_each_element_completed(elem, extra, ie_len)) {
+			err = -EINVAL;
+			goto out;
+		}
 
 		ie = kmemdup(extra, ie_len, GFP_KERNEL);
 		if (!ie) {
Signature · 1 line
2.39.5
maintainer
#1 lore raw
Quoted 33 lines · Wentao Guan

This error path returns while wdev_lock() is still held, so one malformed IE request can permanently block later operations on this wiphy. Route the error through out to release the lock.

Fixes 8b921a899346 ("wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()")
---
 net/wireless/wext-sme.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/wireless/wext-sme.c +4 -2
index be121fa36c514..ba6d8827f64b3 100644
@@ -352,8 +352,10 @@ int cfg80211_wext_siwgenie(struct net_device *dev,
 			/* nothing */
 		}
 
-		if (!for_each_element_completed(elem, extra, ie_len))
-			return -EINVAL;
+		if (!for_each_element_completed(elem, extra, ie_len)) {
+			err = -EINVAL;
+			goto out;
+		}
 
 		ie = kmemdup(extra, ie_len, GFP_KERNEL);
 		if (!ie) {
Signature · 1 line
2.39.5

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

#2 lore raw

Hi,

Quoted 37 lines · Wentao Guan
Quoted 30 lines

This error path returns while wdev_lock() is still held, so one malformed IE request can permanently block later operations on this wiphy. Route the error through out to release the lock.

Fixes 8b921a899346 ("wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()")
---
 net/wireless/wext-sme.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/wireless/wext-sme.c +4 -3
index be121fa36c514..ba6d8827f64b3 100644
@@ -352,8 +352,10 @@ int cfg80211_wext_siwgenie(struct net_device *dev,
 /* nothing */
 }
 
- if (!for_each_element_completed(elem, extra, ie_len))
- return -EINVAL;
+ if (!for_each_element_completed(elem, extra, ie_len)) {
+ err = -EINVAL;
+ goto out;
+ }
 
 ie = kmemdup(extra, ie_len, GFP_KERNEL);
 if (!ie) {
--
Quoted 3 lines

2.39.5

<formletter>

Quoted 8 lines

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

It or an equivalent fix must already exist in Linux mainline (upstream).

This is a trival fix for these stable trees, the problem is not existed in mainline

Quoted 1 line

It must be obviously correct and tested.

It is clearly right.

Quoted 1 line

It cannot be bigger than 100 lines, with context.

It is small./ +4 lines -2 lines

Quoted 1 line

It must follow the Documentation/process/submitting-patches.rst rules.

Its fixes tags point to the stable backport commit ids.

Quoted 2 lines

It must either fix a real bug that bothers people or just add a device ID. To elaborate on the former:
It fixes a problem like an oops, a hang, data corruption, a real security issue, a hardware quirk, a build error (but not for things marked CONFIG_BROKEN), or some “oh, that’s not good” issue.

Its fixes a lock with out unlock, and we no need to backport f42d22d3f79639 ("wifi: cfg80211: define and use wiphy guard")
and guard for older kernel tree.

BRs
Wentao Guan

maintainer
#3 lore raw
Quoted 44 lines · Wentao Guan

Hi,

Quoted 42 lines · Wentao Guan
Quoted 30 lines

This error path returns while wdev_lock() is still held, so one malformed IE request can permanently block later operations on this wiphy. Route the error through out to release the lock.

Fixes 8b921a899346 ("wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()")
---
 net/wireless/wext-sme.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/wireless/wext-sme.c +4 -3
index be121fa36c514..ba6d8827f64b3 100644
@@ -352,8 +352,10 @@ int cfg80211_wext_siwgenie(struct net_device *dev,
 /* nothing */
 }
 
- if (!for_each_element_completed(elem, extra, ie_len))
- return -EINVAL;
+ if (!for_each_element_completed(elem, extra, ie_len)) {
+ err = -EINVAL;
+ goto out;
+ }
 
 ie = kmemdup(extra, ie_len, GFP_KERNEL);
 if (!ie) {
--
Quoted 3 lines

2.39.5

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

Quoted 4 lines
Quoted 3 lines

</formletter>

It or an equivalent fix must already exist in Linux mainline (upstream).

This is a trival fix for these stable trees, the problem is not existed in mainline

Then you need to document the heck out of this why it's not upstream, what upstream commit fixes this id and why you can't just backport that commit (or commits) instead.

And get the needed maintainers to agree that this fix is ok and for them to review it.

Quoted 5 lines
Quoted 2 lines

It must either fix a real bug that bothers people or just add a device ID. To elaborate on the former:
It fixes a problem like an oops, a hang, data corruption, a real security issue, a hardware quirk, a build error (but not for things marked CONFIG_BROKEN), or some “oh, that’s not good” issue.

Its fixes a lock with out unlock, and we no need to backport f42d22d3f79639 ("wifi: cfg80211: define and use wiphy guard")
and guard for older kernel tree.

We have no problem backporting upstream patches to resolve issues. Please always do that instead.

thanks,

greg k-h