aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/wireless/util.c')
-rw-r--r--net/wireless/util.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c
index cd48cdd582c0..ec30e3732c7b 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -5,7 +5,7 @@
5 * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net> 5 * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH 6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright 2017 Intel Deutschland GmbH 7 * Copyright 2017 Intel Deutschland GmbH
8 * Copyright (C) 2018 Intel Corporation 8 * Copyright (C) 2018-2019 Intel Corporation
9 */ 9 */
10#include <linux/export.h> 10#include <linux/export.h>
11#include <linux/bitops.h> 11#include <linux/bitops.h>
@@ -19,6 +19,7 @@
19#include <linux/mpls.h> 19#include <linux/mpls.h>
20#include <linux/gcd.h> 20#include <linux/gcd.h>
21#include <linux/bitfield.h> 21#include <linux/bitfield.h>
22#include <linux/nospec.h>
22#include "core.h" 23#include "core.h"
23#include "rdev-ops.h" 24#include "rdev-ops.h"
24 25
@@ -715,20 +716,25 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb,
715{ 716{
716 unsigned int dscp; 717 unsigned int dscp;
717 unsigned char vlan_priority; 718 unsigned char vlan_priority;
719 unsigned int ret;
718 720
719 /* skb->priority values from 256->263 are magic values to 721 /* skb->priority values from 256->263 are magic values to
720 * directly indicate a specific 802.1d priority. This is used 722 * directly indicate a specific 802.1d priority. This is used
721 * to allow 802.1d priority to be passed directly in from VLAN 723 * to allow 802.1d priority to be passed directly in from VLAN
722 * tags, etc. 724 * tags, etc.
723 */ 725 */
724 if (skb->priority >= 256 && skb->priority <= 263) 726 if (skb->priority >= 256 && skb->priority <= 263) {
725 return skb->priority - 256; 727 ret = skb->priority - 256;
728 goto out;
729 }
726 730
727 if (skb_vlan_tag_present(skb)) { 731 if (skb_vlan_tag_present(skb)) {
728 vlan_priority = (skb_vlan_tag_get(skb) & VLAN_PRIO_MASK) 732 vlan_priority = (skb_vlan_tag_get(skb) & VLAN_PRIO_MASK)
729 >> VLAN_PRIO_SHIFT; 733 >> VLAN_PRIO_SHIFT;
730 if (vlan_priority > 0) 734 if (vlan_priority > 0) {
731 return vlan_priority; 735 ret = vlan_priority;
736 goto out;
737 }
732 } 738 }
733 739
734 switch (skb->protocol) { 740 switch (skb->protocol) {
@@ -747,8 +753,9 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb,
747 if (!mpls) 753 if (!mpls)
748 return 0; 754 return 0;
749 755
750 return (ntohl(mpls->entry) & MPLS_LS_TC_MASK) 756 ret = (ntohl(mpls->entry) & MPLS_LS_TC_MASK)
751 >> MPLS_LS_TC_SHIFT; 757 >> MPLS_LS_TC_SHIFT;
758 goto out;
752 } 759 }
753 case htons(ETH_P_80221): 760 case htons(ETH_P_80221):
754 /* 802.21 is always network control traffic */ 761 /* 802.21 is always network control traffic */
@@ -761,18 +768,24 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb,
761 unsigned int i, tmp_dscp = dscp >> 2; 768 unsigned int i, tmp_dscp = dscp >> 2;
762 769
763 for (i = 0; i < qos_map->num_des; i++) { 770 for (i = 0; i < qos_map->num_des; i++) {
764 if (tmp_dscp == qos_map->dscp_exception[i].dscp) 771 if (tmp_dscp == qos_map->dscp_exception[i].dscp) {
765 return qos_map->dscp_exception[i].up; 772 ret = qos_map->dscp_exception[i].up;
773 goto out;
774 }
766 } 775 }
767 776
768 for (i = 0; i < 8; i++) { 777 for (i = 0; i < 8; i++) {
769 if (tmp_dscp >= qos_map->up[i].low && 778 if (tmp_dscp >= qos_map->up[i].low &&
770 tmp_dscp <= qos_map->up[i].high) 779 tmp_dscp <= qos_map->up[i].high) {
771 return i; 780 ret = i;
781 goto out;
782 }
772 } 783 }
773 } 784 }
774 785
775 return dscp >> 5; 786 ret = dscp >> 5;
787out:
788 return array_index_nospec(ret, IEEE80211_NUM_TIDS);
776} 789}
777EXPORT_SYMBOL(cfg80211_classify8021d); 790EXPORT_SYMBOL(cfg80211_classify8021d);
778 791