[OpenWrt-Devel] [PATCH] mac80211: fix freeing keys for ap iface in ieee80211_do_stop().

Yousong Zhou yszhou4tech at gmail.com
Wed Aug 13 23:58:57 EDT 2014


The patch will fix #17506 and squelch the following WARNING from mac80211.ko

	[  203.770000] ------------[ cut here ]------------
	[  203.770000] WARNING: at /home/yousong/trunk-openwrt/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/compat-wireless-2014-05-22/net/mac80211/driver-ops.h:12 ieee80211_get_key_rx_seq+0x1b8/0x640 [mac80211]()
	[  203.790000] wlan0-1:  Failed check-sdata-in-driver check, flags: 0x0
	[  203.800000] Modules linked in: ath9k ath9k_common pppoe ppp_async iptable_nat ath9k_hw ath pppox ppp_generic nf_nat_ipv4 nf_conntrack_ipv4 mac80211 ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_conntrack xt_comment xt_TCPMSS
	xt_REDIRECT xt_LOG xt_CT slhc nf_nat_irc nf_nat_ftp nf_nat nf_defrag_ipv4 nf_conntrack_irc nf_conntrack_ftp iptable_raw iptable_mangle iptable_filter ipt_REJECT ip_tables crc_ccitt compat ledtrig_usbdev ip6t_REJECT ip6table_raw ip6table_mangle ip6table_filter ip6_tables x_tables
	nf_conntrack_ipv6 nf_conntrack nf_defrag_ipv6 ipv6 arc4 crypto_blkcipher ohci_hcd ehci_platform ehci_hcd gpio_button_hotplug usbcore nls_base usb_common
	[  203.860000] CPU: 0 PID: 954 Comm: hostapd Tainted: G        W    3.10.49 #5
	[  203.860000] Stack : 00000000 00000000 00000000 00000000 80362eba 0000003f 8335a758 83332854
	[  203.860000]    802c0c64 8030f21b 000003ba 80362664 8335a758 83332854 00000000 00000024
	[  203.860000]    00000008 80079040 00000003 80076a4c 831cbae8 83332854 802c2524 8281d9cc
	[  203.860000]    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
	[  203.860000]    00000000 00000000 00000000 00000000 00000000 00000000 00000000 8281d958
	[  203.860000]    ...
	[  203.900000] Call Trace:
	[  203.900000] [<8006e294>] show_stack+0x48/0x70
	[  203.910000] [<80076bbc>] warn_slowpath_common+0x78/0xa8
	[  203.910000] [<80076c18>] warn_slowpath_fmt+0x2c/0x38
	[  203.920000] [<831a49ac>] ieee80211_get_key_rx_seq+0x1b8/0x640 [mac80211]
	[  203.920000]
	[  203.920000] ---[ end trace 1ed35f4cd8a2a9e5 ]---

The original code has a bug of the following form in which "Hello" won't
be printed.

	  7         switch (i) {
	  8                 default:
	  9                         printf("Hello.\n");
	 10		    /* Won't fall through */
	 11                 case 2:
	 12                         printf("World.\n");
	 13         }

Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 ...ng-keys-for-ap-iface-in-ieee80211-do-stop.patch |   37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 package/kernel/mac80211/patches/921-fix-freeing-keys-for-ap-iface-in-ieee80211-do-stop.patch

diff --git a/package/kernel/mac80211/patches/921-fix-freeing-keys-for-ap-iface-in-ieee80211-do-stop.patch b/package/kernel/mac80211/patches/921-fix-freeing-keys-for-ap-iface-in-ieee80211-do-stop.patch
new file mode 100644
index 0000000..1d48bc0
--- /dev/null
+++ b/package/kernel/mac80211/patches/921-fix-freeing-keys-for-ap-iface-in-ieee80211-do-stop.patch
@@ -0,0 +1,37 @@
+Index: compat-wireless-2014-05-22/net/mac80211/iface.c
+===================================================================
+--- compat-wireless-2014-05-22.orig/net/mac80211/iface.c	2014-08-14 11:42:04.100927001 +0800
++++ compat-wireless-2014-05-22/net/mac80211/iface.c	2014-08-14 11:45:51.032928188 +0800
+@@ -912,10 +912,6 @@
+ 
+ 		ieee80211_adjust_monitor_flags(sdata, -1);
+ 		break;
+-	case NL80211_IFTYPE_P2P_DEVICE:
+-		/* relies on synchronize_rcu() below */
+-		RCU_INIT_POINTER(local->p2p_sdata, NULL);
+-		/* fall through */
+ 	default:
+ 		cancel_work_sync(&sdata->work);
+ 		/*
+@@ -929,10 +925,18 @@
+ 		 * another CPU.
+ 		 */
+ 		ieee80211_free_keys(sdata, true);
++		switch(sdata->vif.type) {
++			case NL80211_IFTYPE_P2P_DEVICE:
++				/* relies on synchronize_rcu() below */
++				RCU_INIT_POINTER(local->p2p_sdata, NULL);
++			break;
+ 
+-		/* fall through */
+-	case NL80211_IFTYPE_AP:
+-		skb_queue_purge(&sdata->skb_queue);
++		case NL80211_IFTYPE_AP:
++			skb_queue_purge(&sdata->skb_queue);
++			break;
++		default:
++			break;
++		}
+ 	}
+ 
+ 	sdata->bss = NULL;
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list