300-pending_work.patch 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  1. commit de5f242e0c10e841017e37eb8c38974a642dbca8
  2. Author: Sujith Manoharan <[email protected]>
  3. Date: Tue Jan 28 06:21:59 2014 +0530
  4. ath9k: Fix build error on ARM
  5. Use mdelay instead of udelay to fix this error:
  6. ERROR: "__bad_udelay" [drivers/net/wireless/ath/ath9k/ath9k_hw.ko] undefined!
  7. make[1]: *** [__modpost] Error 1
  8. make: *** [modules] Error 2
  9. Reported-by: Josh Boyer <[email protected]>
  10. Signed-off-by: Sujith Manoharan <[email protected]>
  11. commit 8e3ea7a51dfc61810fcefd947f6edcf61125252a
  12. Author: Geert Uytterhoeven <[email protected]>
  13. Date: Sun Jan 26 11:53:21 2014 +0100
  14. ath9k: Fix uninitialized variable in ath9k_has_tx_pending()
  15. drivers/net/wireless/ath/ath9k/main.c: In function ‘ath9k_has_tx_pending’:
  16. drivers/net/wireless/ath/ath9k/main.c:1869: warning: ‘npend’ may be used uninitialized in this function
  17. Introduced by commit 10e2318103f5941aa70c318afe34bc41f1b98529 ("ath9k:
  18. optimize ath9k_flush").
  19. Signed-off-by: Geert Uytterhoeven <[email protected]>
  20. commit a4a634a6937ebdd827fa58e8fcdb8ca49a3769f6
  21. Author: Emmanuel Grumbach <[email protected]>
  22. Date: Mon Jan 27 11:07:42 2014 +0200
  23. mac80211: release the channel in error path in start_ap
  24. When the driver cannot start the AP or when the assignement
  25. of the beacon goes wrong, we need to unassign the vif.
  26. Cc: [email protected]
  27. Signed-off-by: Emmanuel Grumbach <[email protected]>
  28. Signed-off-by: Johannes Berg <[email protected]>
  29. commit dfb6889a75c601aedb7450b7e606668e77da6679
  30. Author: Johannes Berg <[email protected]>
  31. Date: Wed Jan 22 11:14:19 2014 +0200
  32. cfg80211: send scan results from work queue
  33. Due to the previous commit, when a scan finishes, it is in theory
  34. possible to hit the following sequence:
  35. 1. interface starts being removed
  36. 2. scan is cancelled by driver and cfg80211 is notified
  37. 3. scan done work is scheduled
  38. 4. interface is removed completely, rdev->scan_req is freed,
  39. event sent to userspace but scan done work remains pending
  40. 5. new scan is requested on another virtual interface
  41. 6. scan done work runs, freeing the still-running scan
  42. To fix this situation, hang on to the scan done message and block
  43. new scans while that is the case, and only send the message from
  44. the work function, regardless of whether the scan_req is already
  45. freed from interface removal. This makes step 5 above impossible
  46. and changes step 6 to be
  47. 5. scan done work runs, sending the scan done message
  48. As this can't work for wext, so we send the message immediately,
  49. but this shouldn't be an issue since we still return -EBUSY.
  50. Signed-off-by: Johannes Berg <[email protected]>
  51. commit 45b7ab41fc08627d9a8428cb413d5d84662a9707
  52. Author: Johannes Berg <[email protected]>
  53. Date: Wed Jan 22 11:14:18 2014 +0200
  54. cfg80211: fix scan done race
  55. When an interface/wdev is removed, any ongoing scan should be
  56. cancelled by the driver. This will make it call cfg80211, which
  57. only queues a work struct. If interface/wdev removal is quick
  58. enough, this can leave the scan request pending and processed
  59. only after the interface is gone, causing a use-after-free.
  60. Fix this by making sure the scan request is not pending after
  61. the interface is destroyed. We can't flush or cancel the work
  62. item due to locking concerns, but when it'll run it shouldn't
  63. find anything to do. This leaves a potential issue, if a new
  64. scan gets requested before the work runs, it prematurely stops
  65. the running scan, potentially causing another crash. I'll fix
  66. that in the next patch.
  67. This was particularly observed with P2P_DEVICE wdevs, likely
  68. because freeing them is quicker than freeing netdevs.
  69. Reported-by: Andrei Otcheretianski <[email protected]>
  70. Fixes: 4a58e7c38443 ("cfg80211: don't "leak" uncompleted scans")
  71. Signed-off-by: Johannes Berg <[email protected]>
  72. commit ae04fa489ab31b5a10d3cc8399f52761175d4321
  73. Author: Emmanuel Grumbach <[email protected]>
  74. Date: Thu Jan 23 14:28:16 2014 +0200
  75. mac80211: avoid deadlock revealed by lockdep
  76. sdata->u.ap.request_smps_work can’t be flushed synchronously
  77. under wdev_lock(wdev) since ieee80211_request_smps_ap_work
  78. itself locks the same lock.
  79. While at it, reset the driver_smps_mode when the ap is
  80. stopped to its default: OFF.
  81. This solves:
  82. ======================================================
  83. [ INFO: possible circular locking dependency detected ]
  84. 3.12.0-ipeer+ #2 Tainted: G O
  85. -------------------------------------------------------
  86. rmmod/2867 is trying to acquire lock:
  87. ((&sdata->u.ap.request_smps_work)){+.+...}, at: [<c105b8d0>] flush_work+0x0/0x90
  88. but task is already holding lock:
  89. (&wdev->mtx){+.+.+.}, at: [<f9b32626>] cfg80211_stop_ap+0x26/0x230 [cfg80211]
  90. which lock already depends on the new lock.
  91. the existing dependency chain (in reverse order) is:
  92. -> #1 (&wdev->mtx){+.+.+.}:
  93. [<c10aefa9>] lock_acquire+0x79/0xe0
  94. [<c1607a1a>] mutex_lock_nested+0x4a/0x360
  95. [<fb06288b>] ieee80211_request_smps_ap_work+0x2b/0x50 [mac80211]
  96. [<c105cdd8>] process_one_work+0x198/0x450
  97. [<c105d469>] worker_thread+0xf9/0x320
  98. [<c10669ff>] kthread+0x9f/0xb0
  99. [<c1613397>] ret_from_kernel_thread+0x1b/0x28
  100. -> #0 ((&sdata->u.ap.request_smps_work)){+.+...}:
  101. [<c10ae9df>] __lock_acquire+0x183f/0x1910
  102. [<c10aefa9>] lock_acquire+0x79/0xe0
  103. [<c105b917>] flush_work+0x47/0x90
  104. [<c105d867>] __cancel_work_timer+0x67/0xe0
  105. [<c105d90f>] cancel_work_sync+0xf/0x20
  106. [<fb0765cc>] ieee80211_stop_ap+0x8c/0x340 [mac80211]
  107. [<f9b3268c>] cfg80211_stop_ap+0x8c/0x230 [cfg80211]
  108. [<f9b0d8f9>] cfg80211_leave+0x79/0x100 [cfg80211]
  109. [<f9b0da72>] cfg80211_netdev_notifier_call+0xf2/0x4f0 [cfg80211]
  110. [<c160f2c9>] notifier_call_chain+0x59/0x130
  111. [<c106c6de>] __raw_notifier_call_chain+0x1e/0x30
  112. [<c106c70f>] raw_notifier_call_chain+0x1f/0x30
  113. [<c14f8213>] call_netdevice_notifiers_info+0x33/0x70
  114. [<c14f8263>] call_netdevice_notifiers+0x13/0x20
  115. [<c14f82a4>] __dev_close_many+0x34/0xb0
  116. [<c14f83fe>] dev_close_many+0x6e/0xc0
  117. [<c14f9c77>] rollback_registered_many+0xa7/0x1f0
  118. [<c14f9dd4>] unregister_netdevice_many+0x14/0x60
  119. [<fb06f4d9>] ieee80211_remove_interfaces+0xe9/0x170 [mac80211]
  120. [<fb055116>] ieee80211_unregister_hw+0x56/0x110 [mac80211]
  121. [<fa3e9396>] iwl_op_mode_mvm_stop+0x26/0xe0 [iwlmvm]
  122. [<f9b9d8ca>] _iwl_op_mode_stop+0x3a/0x70 [iwlwifi]
  123. [<f9b9d96f>] iwl_opmode_deregister+0x6f/0x90 [iwlwifi]
  124. [<fa405179>] __exit_compat+0xd/0x19 [iwlmvm]
  125. [<c10b8bf9>] SyS_delete_module+0x179/0x2b0
  126. [<c1613421>] sysenter_do_call+0x12/0x32
  127. Fixes: 687da132234f ("mac80211: implement SMPS for AP")
  128. Cc: <[email protected]> [3.13]
  129. Reported-by: Ilan Peer <[email protected]>
  130. Signed-off-by: Emmanuel Grumbach <[email protected]>
  131. Signed-off-by: Johannes Berg <[email protected]>
  132. commit 178b205e96217164fd7c30113464250d0b6f5eca
  133. Author: Johannes Berg <[email protected]>
  134. Date: Thu Jan 23 16:32:29 2014 +0100
  135. cfg80211: re-enable 5/10 MHz support
  136. Unfortunately I forgot this during the merge window, but the
  137. patch seems small enough to go in as a fix. The userspace API
  138. bug that was the reason for disabling it has long been fixed.
  139. Signed-off-by: Johannes Berg <[email protected]>
  140. commit 110a1c79acda14edc83b7c8dc5af9c7ddd23eb61
  141. Author: Pontus Fuchs <[email protected]>
  142. Date: Thu Jan 16 15:00:40 2014 +0100
  143. nl80211: Reset split_start when netlink skb is exhausted
  144. When the netlink skb is exhausted split_start is left set. In the
  145. subsequent retry, with a larger buffer, the dump is continued from the
  146. failing point instead of from the beginning.
  147. This was causing my rt28xx based USB dongle to now show up when
  148. running "iw list" with an old iw version without split dump support.
  149. Cc: [email protected]
  150. Fixes: 3713b4e364ef ("nl80211: allow splitting wiphy information in dumps")
  151. Signed-off-by: Pontus Fuchs <[email protected]>
  152. [avoid the entire workaround when state->split is set]
  153. Signed-off-by: Johannes Berg <[email protected]>
  154. commit b4c31b45ffc7ef110fa9ecc34d7878fe7c5b9da4
  155. Author: Eliad Peller <[email protected]>
  156. Date: Sun Jan 12 11:06:37 2014 +0200
  157. mac80211: move roc cookie assignment earlier
  158. ieee80211_start_roc_work() might add a new roc
  159. to existing roc, and tell cfg80211 it has already
  160. started.
  161. However, this might happen before the roc cookie
  162. was set, resulting in REMAIN_ON_CHANNEL (started)
  163. event with null cookie. Consequently, it can make
  164. wpa_supplicant go out of sync.
  165. Fix it by setting the roc cookie earlier.
  166. Cc: [email protected]
  167. Signed-off-by: Eliad Peller <[email protected]>
  168. Signed-off-by: Johannes Berg <[email protected]>
  169. commit cfdc9157bfd7bcf88ab4dae08873a9907eba984c
  170. Author: Johannes Berg <[email protected]>
  171. Date: Fri Jan 24 14:06:29 2014 +0100
  172. nl80211: send event when AP operation is stopped
  173. There are a few cases, e.g. suspend, where an AP interface is
  174. stopped by the kernel rather than by userspace request, most
  175. commonly when suspending. To let userspace know about this,
  176. send the NL80211_CMD_STOP_AP command as an event every time
  177. an AP interface is stopped. This also happens when userspace
  178. did in fact request the AP stop, but that's not a problem.
  179. For full-MAC drivers this may need to be extended to also
  180. cover cases where the device stopped the AP operation for
  181. some reason, this a bit more complicated because then all
  182. cfg80211 state also needs to be reset; such API is not part
  183. of this patch.
  184. Signed-off-by: Johannes Berg <[email protected]>
  185. commit d5d567eda7704f190379ca852a8f9a4112e3eee3
  186. Author: Johannes Berg <[email protected]>
  187. Date: Thu Jan 23 16:20:29 2014 +0100
  188. mac80211: add length check in ieee80211_is_robust_mgmt_frame()
  189. A few places weren't checking that the frame passed to the
  190. function actually has enough data even though the function
  191. clearly documents it must have a payload byte. Make this
  192. safer by changing the function to take an skb and checking
  193. the length inside. The old version is preserved for now as
  194. the rtl* drivers use it and don't have a correct skb.
  195. Signed-off-by: Johannes Berg <[email protected]>
  196. commit f8f6d212a047fc65c7d3442dfc038f65517236fc
  197. Author: Johannes Berg <[email protected]>
  198. Date: Fri Jan 24 10:53:53 2014 +0100
  199. nl80211: fix scheduled scan RSSI matchset attribute confusion
  200. The scheduled scan matchsets were intended to be a list of filters,
  201. with the found BSS having to pass at least one of them to be passed
  202. to the host. When the RSSI attribute was added, however, this was
  203. broken and currently wpa_supplicant adds that attribute in its own
  204. matchset; however, it doesn't intend that to mean that anything
  205. that passes the RSSI filter should be passed to the host, instead
  206. it wants it to mean that everything needs to also have higher RSSI.
  207. This is semantically problematic because we have a list of filters
  208. like [ SSID1, SSID2, SSID3, RSSI ] with no real indication which
  209. one should be OR'ed and which one AND'ed.
  210. To fix this, move the RSSI filter attribute into each matchset. As
  211. we need to stay backward compatible, treat a matchset with only the
  212. RSSI attribute as a "default RSSI filter" for all other matchsets,
  213. but only if there are other matchsets (an RSSI-only matchset by
  214. itself is still desirable.)
  215. To make driver implementation easier, keep a global min_rssi_thold
  216. for the entire request as well. The only affected driver is ath6kl.
  217. I found this when I looked into the code after Raja Mani submitted
  218. a patch fixing the n_match_sets calculation to disregard the RSSI,
  219. but that patch didn't address the semantic issue.
  220. Reported-by: Raja Mani <[email protected]>
  221. Acked-by: Luciano Coelho <[email protected]>
  222. Signed-off-by: Johannes Berg <[email protected]>
  223. commit de553e8545e65a6dc4e45f43df7e1443d4291922
  224. Author: Johannes Berg <[email protected]>
  225. Date: Fri Jan 24 10:17:47 2014 +0100
  226. nl80211: check nla_parse() return values
  227. If there's a policy, then nla_parse() return values must be
  228. checked, otherwise the policy is useless and there's nothing
  229. that ensures the attributes are actually what we expect them
  230. to be.
  231. Signed-off-by: Johannes Berg <[email protected]>
  232. commit 652204a0733e9e1c54661d6f9d36e2e1e3b22bb1
  233. Author: Karl Beldan <[email protected]>
  234. Date: Thu Jan 23 20:06:34 2014 +0100
  235. mac80211: send {ADD,DEL}BA on AC_VO like other mgmt frames, as per spec
  236. ATM, {ADD,DEL}BA and BAR frames are sent on the AC matching the TID of
  237. the BA parameters. In the discussion [1] about this patch, Johannes
  238. recalled that it fixed some races with the DELBA and indeed this
  239. behavior was introduced in [2].
  240. While [2] is right for the BARs, the part queueing the {ADD,DEL}BAs on
  241. their BA params TID AC violates the spec and is more a workaround for
  242. some drivers. Helmut expressed some concerns wrt such drivers, in
  243. particular DELBAs in rt2x00.
  244. ATM, DELBAs are sent after a driver has called (hence "purposely")
  245. ieee80211_start_tx_ba_cb_irqsafe and Johannes and Emmanuel gave some
  246. details wrt intentions behind the split of the IEEE80211_AMPDU_TX_STOP_*
  247. given to the driver ampdu_action supposed to call this function, which
  248. could prove handy to people trying to do the right thing in faulty
  249. drivers (if their fw/hw don't get in their way).
  250. [1] http://mid.gmane.org/[email protected]
  251. [2] Commit: cf6bb79ad828 ("mac80211: Use appropriate TID for sending BAR, ADDBA and DELBA frames")
  252. Signed-off-by: Karl Beldan <[email protected]>
  253. Cc: Helmut Schaa <[email protected]>
  254. Cc: Emmanuel Grumbach <[email protected]>
  255. Signed-off-by: Johannes Berg <[email protected]>
  256. --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
  257. +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
  258. @@ -3256,6 +3256,15 @@ static int ath6kl_cfg80211_sscan_start(s
  259. struct ath6kl_vif *vif = netdev_priv(dev);
  260. u16 interval;
  261. int ret, rssi_thold;
  262. + int n_match_sets = request->n_match_sets;
  263. +
  264. + /*
  265. + * If there's a matchset w/o an SSID, then assume it's just for
  266. + * the RSSI (nothing else is currently supported) and ignore it.
  267. + * The device only supports a global RSSI filter that we set below.
  268. + */
  269. + if (n_match_sets == 1 && !request->match_sets[0].ssid.ssid_len)
  270. + n_match_sets = 0;
  271. if (ar->state != ATH6KL_STATE_ON)
  272. return -EIO;
  273. @@ -3268,11 +3277,11 @@ static int ath6kl_cfg80211_sscan_start(s
  274. ret = ath6kl_set_probed_ssids(ar, vif, request->ssids,
  275. request->n_ssids,
  276. request->match_sets,
  277. - request->n_match_sets);
  278. + n_match_sets);
  279. if (ret < 0)
  280. return ret;
  281. - if (!request->n_match_sets) {
  282. + if (!n_match_sets) {
  283. ret = ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
  284. ALL_BSS_FILTER, 0);
  285. if (ret < 0)
  286. @@ -3286,12 +3295,12 @@ static int ath6kl_cfg80211_sscan_start(s
  287. if (test_bit(ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD,
  288. ar->fw_capabilities)) {
  289. - if (request->rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
  290. + if (request->min_rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
  291. rssi_thold = 0;
  292. - else if (request->rssi_thold < -127)
  293. + else if (request->min_rssi_thold < -127)
  294. rssi_thold = -127;
  295. else
  296. - rssi_thold = request->rssi_thold;
  297. + rssi_thold = request->min_rssi_thold;
  298. ret = ath6kl_wmi_set_rssi_filter_cmd(ar->wmi, vif->fw_vif_idx,
  299. rssi_thold);
  300. --- a/drivers/net/wireless/ath/ath9k/hw.c
  301. +++ b/drivers/net/wireless/ath/ath9k/hw.c
  302. @@ -1316,7 +1316,7 @@ static bool ath9k_hw_set_reset(struct at
  303. if (AR_SREV_9300_20_OR_LATER(ah))
  304. udelay(50);
  305. else if (AR_SREV_9100(ah))
  306. - udelay(10000);
  307. + mdelay(10);
  308. else
  309. udelay(100);
  310. @@ -2051,9 +2051,8 @@ static bool ath9k_hw_set_power_awake(str
  311. REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
  312. AR_RTC_FORCE_WAKE_EN);
  313. -
  314. if (AR_SREV_9100(ah))
  315. - udelay(10000);
  316. + mdelay(10);
  317. else
  318. udelay(50);
  319. --- a/drivers/net/wireless/ath/ath9k/main.c
  320. +++ b/drivers/net/wireless/ath/ath9k/main.c
  321. @@ -1866,7 +1866,7 @@ static void ath9k_set_coverage_class(str
  322. static bool ath9k_has_tx_pending(struct ath_softc *sc)
  323. {
  324. - int i, npend;
  325. + int i, npend = 0;
  326. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  327. if (!ATH_TXQ_SETUP(sc, i))
  328. --- a/drivers/net/wireless/iwlwifi/mvm/scan.c
  329. +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
  330. @@ -595,6 +595,9 @@ static void iwl_scan_offload_build_ssid(
  331. * config match list.
  332. */
  333. for (i = 0; i < req->n_match_sets && i < PROBE_OPTION_MAX; i++) {
  334. + /* skip empty SSID matchsets */
  335. + if (!req->match_sets[i].ssid.ssid_len)
  336. + continue;
  337. scan->direct_scan[i].id = WLAN_EID_SSID;
  338. scan->direct_scan[i].len = req->match_sets[i].ssid.ssid_len;
  339. memcpy(scan->direct_scan[i].ssid, req->match_sets[i].ssid.ssid,
  340. --- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
  341. +++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
  342. @@ -452,7 +452,7 @@ bool rtl88ee_rx_query_desc(struct ieee80
  343. /* During testing, hdr was NULL */
  344. return false;
  345. }
  346. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  347. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  348. (ieee80211_has_protected(hdr->frame_control)))
  349. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  350. else
  351. --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
  352. +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
  353. @@ -393,7 +393,7 @@ bool rtl92ce_rx_query_desc(struct ieee80
  354. /* In testing, hdr was NULL here */
  355. return false;
  356. }
  357. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  358. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  359. (ieee80211_has_protected(hdr->frame_control)))
  360. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  361. else
  362. --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
  363. +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
  364. @@ -310,7 +310,7 @@ bool rtl92se_rx_query_desc(struct ieee80
  365. /* during testing, hdr was NULL here */
  366. return false;
  367. }
  368. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  369. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  370. (ieee80211_has_protected(hdr->frame_control)))
  371. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  372. else
  373. --- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
  374. +++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
  375. @@ -334,7 +334,7 @@ bool rtl8723ae_rx_query_desc(struct ieee
  376. /* during testing, hdr could be NULL here */
  377. return false;
  378. }
  379. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  380. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  381. (ieee80211_has_protected(hdr->frame_control)))
  382. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  383. else
  384. --- a/include/linux/ieee80211.h
  385. +++ b/include/linux/ieee80211.h
  386. @@ -2192,10 +2192,10 @@ static inline u8 *ieee80211_get_DA(struc
  387. }
  388. /**
  389. - * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  390. + * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  391. * @hdr: the frame (buffer must include at least the first octet of payload)
  392. */
  393. -static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  394. +static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  395. {
  396. if (ieee80211_is_disassoc(hdr->frame_control) ||
  397. ieee80211_is_deauth(hdr->frame_control))
  398. @@ -2224,6 +2224,17 @@ static inline bool ieee80211_is_robust_m
  399. }
  400. /**
  401. + * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
  402. + * @skb: the skb containing the frame, length will be checked
  403. + */
  404. +static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
  405. +{
  406. + if (skb->len < 25)
  407. + return false;
  408. + return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
  409. +}
  410. +
  411. +/**
  412. * ieee80211_is_public_action - check if frame is a public action frame
  413. * @hdr: the frame
  414. * @len: length of the frame
  415. --- a/include/net/cfg80211.h
  416. +++ b/include/net/cfg80211.h
  417. @@ -1395,9 +1395,11 @@ struct cfg80211_scan_request {
  418. * struct cfg80211_match_set - sets of attributes to match
  419. *
  420. * @ssid: SSID to be matched
  421. + * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  422. */
  423. struct cfg80211_match_set {
  424. struct cfg80211_ssid ssid;
  425. + s32 rssi_thold;
  426. };
  427. /**
  428. @@ -1420,7 +1422,8 @@ struct cfg80211_match_set {
  429. * @dev: the interface
  430. * @scan_start: start time of the scheduled scan
  431. * @channels: channels to scan
  432. - * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  433. + * @min_rssi_thold: for drivers only supporting a single threshold, this
  434. + * contains the minimum over all matchsets
  435. */
  436. struct cfg80211_sched_scan_request {
  437. struct cfg80211_ssid *ssids;
  438. @@ -1433,7 +1436,7 @@ struct cfg80211_sched_scan_request {
  439. u32 flags;
  440. struct cfg80211_match_set *match_sets;
  441. int n_match_sets;
  442. - s32 rssi_thold;
  443. + s32 min_rssi_thold;
  444. /* internal */
  445. struct wiphy *wiphy;
  446. --- a/include/uapi/linux/nl80211.h
  447. +++ b/include/uapi/linux/nl80211.h
  448. @@ -2442,9 +2442,15 @@ enum nl80211_reg_rule_attr {
  449. * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
  450. * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
  451. * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
  452. - * only report BSS with matching SSID.
  453. + * only report BSS with matching SSID.
  454. * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
  455. - * BSS in scan results. Filtering is turned off if not specified.
  456. + * BSS in scan results. Filtering is turned off if not specified. Note that
  457. + * if this attribute is in a match set of its own, then it is treated as
  458. + * the default value for all matchsets with an SSID, rather than being a
  459. + * matchset of its own without an RSSI filter. This is due to problems with
  460. + * how this API was implemented in the past. Also, due to the same problem,
  461. + * the only way to create a matchset with only an RSSI filter (with this
  462. + * attribute) is if there's only a single matchset with the RSSI attribute.
  463. * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
  464. * attribute number currently defined
  465. * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
  466. --- a/net/mac80211/agg-tx.c
  467. +++ b/net/mac80211/agg-tx.c
  468. @@ -107,7 +107,7 @@ static void ieee80211_send_addba_request
  469. mgmt->u.action.u.addba_req.start_seq_num =
  470. cpu_to_le16(start_seq_num << 4);
  471. - ieee80211_tx_skb_tid(sdata, skb, tid);
  472. + ieee80211_tx_skb(sdata, skb);
  473. }
  474. void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn)
  475. --- a/net/mac80211/cfg.c
  476. +++ b/net/mac80211/cfg.c
  477. @@ -1021,8 +1021,10 @@ static int ieee80211_start_ap(struct wip
  478. IEEE80211_P2P_OPPPS_ENABLE_BIT;
  479. err = ieee80211_assign_beacon(sdata, &params->beacon);
  480. - if (err < 0)
  481. + if (err < 0) {
  482. + ieee80211_vif_release_channel(sdata);
  483. return err;
  484. + }
  485. changed |= err;
  486. err = drv_start_ap(sdata->local, sdata);
  487. @@ -1032,6 +1034,7 @@ static int ieee80211_start_ap(struct wip
  488. if (old)
  489. kfree_rcu(old, rcu_head);
  490. RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
  491. + ieee80211_vif_release_channel(sdata);
  492. return err;
  493. }
  494. @@ -1090,8 +1093,6 @@ static int ieee80211_stop_ap(struct wiph
  495. kfree(sdata->u.ap.next_beacon);
  496. sdata->u.ap.next_beacon = NULL;
  497. - cancel_work_sync(&sdata->u.ap.request_smps_work);
  498. -
  499. /* turn off carrier for this interface and dependent VLANs */
  500. list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
  501. netif_carrier_off(vlan->dev);
  502. @@ -1103,6 +1104,7 @@ static int ieee80211_stop_ap(struct wiph
  503. kfree_rcu(old_beacon, rcu_head);
  504. if (old_probe_resp)
  505. kfree_rcu(old_probe_resp, rcu_head);
  506. + sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
  507. __sta_info_flush(sdata, true);
  508. ieee80211_free_keys(sdata, true);
  509. @@ -2638,6 +2640,24 @@ static int ieee80211_start_roc_work(stru
  510. INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
  511. INIT_LIST_HEAD(&roc->dependents);
  512. + /*
  513. + * cookie is either the roc cookie (for normal roc)
  514. + * or the SKB (for mgmt TX)
  515. + */
  516. + if (!txskb) {
  517. + /* local->mtx protects this */
  518. + local->roc_cookie_counter++;
  519. + roc->cookie = local->roc_cookie_counter;
  520. + /* wow, you wrapped 64 bits ... more likely a bug */
  521. + if (WARN_ON(roc->cookie == 0)) {
  522. + roc->cookie = 1;
  523. + local->roc_cookie_counter++;
  524. + }
  525. + *cookie = roc->cookie;
  526. + } else {
  527. + *cookie = (unsigned long)txskb;
  528. + }
  529. +
  530. /* if there's one pending or we're scanning, queue this one */
  531. if (!list_empty(&local->roc_list) ||
  532. local->scanning || local->radar_detect_enabled)
  533. @@ -2772,24 +2792,6 @@ static int ieee80211_start_roc_work(stru
  534. if (!queued)
  535. list_add_tail(&roc->list, &local->roc_list);
  536. - /*
  537. - * cookie is either the roc cookie (for normal roc)
  538. - * or the SKB (for mgmt TX)
  539. - */
  540. - if (!txskb) {
  541. - /* local->mtx protects this */
  542. - local->roc_cookie_counter++;
  543. - roc->cookie = local->roc_cookie_counter;
  544. - /* wow, you wrapped 64 bits ... more likely a bug */
  545. - if (WARN_ON(roc->cookie == 0)) {
  546. - roc->cookie = 1;
  547. - local->roc_cookie_counter++;
  548. - }
  549. - *cookie = roc->cookie;
  550. - } else {
  551. - *cookie = (unsigned long)txskb;
  552. - }
  553. -
  554. return 0;
  555. }
  556. --- a/net/mac80211/ht.c
  557. +++ b/net/mac80211/ht.c
  558. @@ -375,7 +375,7 @@ void ieee80211_send_delba(struct ieee802
  559. mgmt->u.action.u.delba.params = cpu_to_le16(params);
  560. mgmt->u.action.u.delba.reason_code = cpu_to_le16(reason_code);
  561. - ieee80211_tx_skb_tid(sdata, skb, tid);
  562. + ieee80211_tx_skb(sdata, skb);
  563. }
  564. void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
  565. @@ -466,7 +466,9 @@ void ieee80211_request_smps_ap_work(stru
  566. u.ap.request_smps_work);
  567. sdata_lock(sdata);
  568. - __ieee80211_request_smps_ap(sdata, sdata->u.ap.driver_smps_mode);
  569. + if (sdata_dereference(sdata->u.ap.beacon, sdata))
  570. + __ieee80211_request_smps_ap(sdata,
  571. + sdata->u.ap.driver_smps_mode);
  572. sdata_unlock(sdata);
  573. }
  574. --- a/net/mac80211/iface.c
  575. +++ b/net/mac80211/iface.c
  576. @@ -770,12 +770,19 @@ static void ieee80211_do_stop(struct iee
  577. ieee80211_roc_purge(local, sdata);
  578. - if (sdata->vif.type == NL80211_IFTYPE_STATION)
  579. + switch (sdata->vif.type) {
  580. + case NL80211_IFTYPE_STATION:
  581. ieee80211_mgd_stop(sdata);
  582. -
  583. - if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
  584. + break;
  585. + case NL80211_IFTYPE_ADHOC:
  586. ieee80211_ibss_stop(sdata);
  587. -
  588. + break;
  589. + case NL80211_IFTYPE_AP:
  590. + cancel_work_sync(&sdata->u.ap.request_smps_work);
  591. + break;
  592. + default:
  593. + break;
  594. + }
  595. /*
  596. * Remove all stations associated with this interface.
  597. --- a/net/mac80211/rx.c
  598. +++ b/net/mac80211/rx.c
  599. @@ -599,10 +599,10 @@ static int ieee80211_is_unicast_robust_m
  600. {
  601. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  602. - if (skb->len < 24 || is_multicast_ether_addr(hdr->addr1))
  603. + if (is_multicast_ether_addr(hdr->addr1))
  604. return 0;
  605. - return ieee80211_is_robust_mgmt_frame(hdr);
  606. + return ieee80211_is_robust_mgmt_frame(skb);
  607. }
  608. @@ -610,10 +610,10 @@ static int ieee80211_is_multicast_robust
  609. {
  610. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  611. - if (skb->len < 24 || !is_multicast_ether_addr(hdr->addr1))
  612. + if (!is_multicast_ether_addr(hdr->addr1))
  613. return 0;
  614. - return ieee80211_is_robust_mgmt_frame(hdr);
  615. + return ieee80211_is_robust_mgmt_frame(skb);
  616. }
  617. @@ -626,7 +626,7 @@ static int ieee80211_get_mmie_keyidx(str
  618. if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da))
  619. return -1;
  620. - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) hdr))
  621. + if (!ieee80211_is_robust_mgmt_frame(skb))
  622. return -1; /* not a robust management frame */
  623. mmie = (struct ieee80211_mmie *)
  624. @@ -1845,8 +1845,7 @@ static int ieee80211_drop_unencrypted_mg
  625. * having configured keys.
  626. */
  627. if (unlikely(ieee80211_is_action(fc) && !rx->key &&
  628. - ieee80211_is_robust_mgmt_frame(
  629. - (struct ieee80211_hdr *) rx->skb->data)))
  630. + ieee80211_is_robust_mgmt_frame(rx->skb)))
  631. return -EACCES;
  632. }
  633. --- a/net/mac80211/tx.c
  634. +++ b/net/mac80211/tx.c
  635. @@ -452,8 +452,7 @@ static int ieee80211_use_mfp(__le16 fc,
  636. if (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP))
  637. return 0;
  638. - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *)
  639. - skb->data))
  640. + if (!ieee80211_is_robust_mgmt_frame(skb))
  641. return 0;
  642. return 1;
  643. @@ -567,7 +566,7 @@ ieee80211_tx_h_select_key(struct ieee802
  644. tx->key = key;
  645. else if (ieee80211_is_mgmt(hdr->frame_control) &&
  646. is_multicast_ether_addr(hdr->addr1) &&
  647. - ieee80211_is_robust_mgmt_frame(hdr) &&
  648. + ieee80211_is_robust_mgmt_frame(tx->skb) &&
  649. (key = rcu_dereference(tx->sdata->default_mgmt_key)))
  650. tx->key = key;
  651. else if (is_multicast_ether_addr(hdr->addr1) &&
  652. @@ -582,12 +581,12 @@ ieee80211_tx_h_select_key(struct ieee802
  653. tx->key = NULL;
  654. else if (tx->skb->protocol == tx->sdata->control_port_protocol)
  655. tx->key = NULL;
  656. - else if (ieee80211_is_robust_mgmt_frame(hdr) &&
  657. + else if (ieee80211_is_robust_mgmt_frame(tx->skb) &&
  658. !(ieee80211_is_action(hdr->frame_control) &&
  659. tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))
  660. tx->key = NULL;
  661. else if (ieee80211_is_mgmt(hdr->frame_control) &&
  662. - !ieee80211_is_robust_mgmt_frame(hdr))
  663. + !ieee80211_is_robust_mgmt_frame(tx->skb))
  664. tx->key = NULL;
  665. else {
  666. I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
  667. --- a/net/mac80211/wpa.c
  668. +++ b/net/mac80211/wpa.c
  669. @@ -499,7 +499,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
  670. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  671. if (!ieee80211_is_data(hdr->frame_control) &&
  672. - !ieee80211_is_robust_mgmt_frame(hdr))
  673. + !ieee80211_is_robust_mgmt_frame(skb))
  674. return RX_CONTINUE;
  675. data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN -
  676. --- a/net/wireless/ap.c
  677. +++ b/net/wireless/ap.c
  678. @@ -30,6 +30,7 @@ static int __cfg80211_stop_ap(struct cfg
  679. wdev->channel = NULL;
  680. wdev->ssid_len = 0;
  681. rdev_set_qos_map(rdev, dev, NULL);
  682. + nl80211_send_ap_stopped(wdev);
  683. }
  684. return err;
  685. --- a/net/wireless/core.c
  686. +++ b/net/wireless/core.c
  687. @@ -203,8 +203,11 @@ void cfg80211_stop_p2p_device(struct cfg
  688. rdev->opencount--;
  689. - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
  690. - !rdev->scan_req->notified);
  691. + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
  692. + if (WARN_ON(!rdev->scan_req->notified))
  693. + rdev->scan_req->aborted = true;
  694. + ___cfg80211_scan_done(rdev, false);
  695. + }
  696. }
  697. static int cfg80211_rfkill_set_block(void *data, bool blocked)
  698. @@ -447,9 +450,6 @@ int wiphy_register(struct wiphy *wiphy)
  699. int i;
  700. u16 ifmodes = wiphy->interface_modes;
  701. - /* support for 5/10 MHz is broken due to nl80211 API mess - disable */
  702. - wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_5_10_MHZ;
  703. -
  704. /*
  705. * There are major locking problems in nl80211/mac80211 for CSA,
  706. * disable for all drivers until this has been reworked.
  707. @@ -875,8 +875,11 @@ static int cfg80211_netdev_notifier_call
  708. break;
  709. case NETDEV_DOWN:
  710. cfg80211_update_iface_num(rdev, wdev->iftype, -1);
  711. - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
  712. - !rdev->scan_req->notified);
  713. + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
  714. + if (WARN_ON(!rdev->scan_req->notified))
  715. + rdev->scan_req->aborted = true;
  716. + ___cfg80211_scan_done(rdev, false);
  717. + }
  718. if (WARN_ON(rdev->sched_scan_req &&
  719. rdev->sched_scan_req->dev == wdev->netdev)) {
  720. --- a/net/wireless/core.h
  721. +++ b/net/wireless/core.h
  722. @@ -62,6 +62,7 @@ struct cfg80211_registered_device {
  723. struct rb_root bss_tree;
  724. u32 bss_generation;
  725. struct cfg80211_scan_request *scan_req; /* protected by RTNL */
  726. + struct sk_buff *scan_msg;
  727. struct cfg80211_sched_scan_request *sched_scan_req;
  728. unsigned long suspend_at;
  729. struct work_struct scan_done_wk;
  730. @@ -361,7 +362,8 @@ int cfg80211_validate_key_settings(struc
  731. struct key_params *params, int key_idx,
  732. bool pairwise, const u8 *mac_addr);
  733. void __cfg80211_scan_done(struct work_struct *wk);
  734. -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev);
  735. +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
  736. + bool send_message);
  737. void __cfg80211_sched_scan_results(struct work_struct *wk);
  738. int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
  739. bool driver_initiated);
  740. --- a/net/wireless/nl80211.c
  741. +++ b/net/wireless/nl80211.c
  742. @@ -1723,9 +1723,10 @@ static int nl80211_dump_wiphy(struct sk_
  743. * We can then retry with the larger buffer.
  744. */
  745. if ((ret == -ENOBUFS || ret == -EMSGSIZE) &&
  746. - !skb->len &&
  747. + !skb->len && !state->split &&
  748. cb->min_dump_alloc < 4096) {
  749. cb->min_dump_alloc = 4096;
  750. + state->split_start = 0;
  751. rtnl_unlock();
  752. return 1;
  753. }
  754. @@ -2047,10 +2048,12 @@ static int nl80211_set_wiphy(struct sk_b
  755. nla_for_each_nested(nl_txq_params,
  756. info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
  757. rem_txq_params) {
  758. - nla_parse(tb, NL80211_TXQ_ATTR_MAX,
  759. - nla_data(nl_txq_params),
  760. - nla_len(nl_txq_params),
  761. - txq_params_policy);
  762. + result = nla_parse(tb, NL80211_TXQ_ATTR_MAX,
  763. + nla_data(nl_txq_params),
  764. + nla_len(nl_txq_params),
  765. + txq_params_policy);
  766. + if (result)
  767. + goto bad_res;
  768. result = parse_txq_params(tb, &txq_params);
  769. if (result)
  770. goto bad_res;
  771. @@ -5210,9 +5213,11 @@ static int nl80211_set_reg(struct sk_buf
  772. nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
  773. rem_reg_rules) {
  774. - nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
  775. - nla_data(nl_reg_rule), nla_len(nl_reg_rule),
  776. - reg_rule_policy);
  777. + r = nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
  778. + nla_data(nl_reg_rule), nla_len(nl_reg_rule),
  779. + reg_rule_policy);
  780. + if (r)
  781. + goto bad_reg;
  782. r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
  783. if (r)
  784. goto bad_reg;
  785. @@ -5277,7 +5282,7 @@ static int nl80211_trigger_scan(struct s
  786. if (!rdev->ops->scan)
  787. return -EOPNOTSUPP;
  788. - if (rdev->scan_req) {
  789. + if (rdev->scan_req || rdev->scan_msg) {
  790. err = -EBUSY;
  791. goto unlock;
  792. }
  793. @@ -5475,6 +5480,7 @@ static int nl80211_start_sched_scan(stru
  794. enum ieee80211_band band;
  795. size_t ie_len;
  796. struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
  797. + s32 default_match_rssi = NL80211_SCAN_RSSI_THOLD_OFF;
  798. if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) ||
  799. !rdev->ops->sched_scan_start)
  800. @@ -5509,11 +5515,40 @@ static int nl80211_start_sched_scan(stru
  801. if (n_ssids > wiphy->max_sched_scan_ssids)
  802. return -EINVAL;
  803. - if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH])
  804. + /*
  805. + * First, count the number of 'real' matchsets. Due to an issue with
  806. + * the old implementation, matchsets containing only the RSSI attribute
  807. + * (NL80211_SCHED_SCAN_MATCH_ATTR_RSSI) are considered as the 'default'
  808. + * RSSI for all matchsets, rather than their own matchset for reporting
  809. + * all APs with a strong RSSI. This is needed to be compatible with
  810. + * older userspace that treated a matchset with only the RSSI as the
  811. + * global RSSI for all other matchsets - if there are other matchsets.
  812. + */
  813. + if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) {
  814. nla_for_each_nested(attr,
  815. info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
  816. - tmp)
  817. - n_match_sets++;
  818. + tmp) {
  819. + struct nlattr *rssi;
  820. +
  821. + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
  822. + nla_data(attr), nla_len(attr),
  823. + nl80211_match_policy);
  824. + if (err)
  825. + return err;
  826. + /* add other standalone attributes here */
  827. + if (tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]) {
  828. + n_match_sets++;
  829. + continue;
  830. + }
  831. + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
  832. + if (rssi)
  833. + default_match_rssi = nla_get_s32(rssi);
  834. + }
  835. + }
  836. +
  837. + /* However, if there's no other matchset, add the RSSI one */
  838. + if (!n_match_sets && default_match_rssi != NL80211_SCAN_RSSI_THOLD_OFF)
  839. + n_match_sets = 1;
  840. if (n_match_sets > wiphy->max_match_sets)
  841. return -EINVAL;
  842. @@ -5634,11 +5669,22 @@ static int nl80211_start_sched_scan(stru
  843. tmp) {
  844. struct nlattr *ssid, *rssi;
  845. - nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
  846. - nla_data(attr), nla_len(attr),
  847. - nl80211_match_policy);
  848. + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
  849. + nla_data(attr), nla_len(attr),
  850. + nl80211_match_policy);
  851. + if (err)
  852. + goto out_free;
  853. ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID];
  854. if (ssid) {
  855. + if (WARN_ON(i >= n_match_sets)) {
  856. + /* this indicates a programming error,
  857. + * the loop above should have verified
  858. + * things properly
  859. + */
  860. + err = -EINVAL;
  861. + goto out_free;
  862. + }
  863. +
  864. if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) {
  865. err = -EINVAL;
  866. goto out_free;
  867. @@ -5647,15 +5693,28 @@ static int nl80211_start_sched_scan(stru
  868. nla_data(ssid), nla_len(ssid));
  869. request->match_sets[i].ssid.ssid_len =
  870. nla_len(ssid);
  871. + /* special attribute - old implemenation w/a */
  872. + request->match_sets[i].rssi_thold =
  873. + default_match_rssi;
  874. + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
  875. + if (rssi)
  876. + request->match_sets[i].rssi_thold =
  877. + nla_get_s32(rssi);
  878. }
  879. - rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
  880. - if (rssi)
  881. - request->rssi_thold = nla_get_u32(rssi);
  882. - else
  883. - request->rssi_thold =
  884. - NL80211_SCAN_RSSI_THOLD_OFF;
  885. i++;
  886. }
  887. +
  888. + /* there was no other matchset, so the RSSI one is alone */
  889. + if (i == 0)
  890. + request->match_sets[0].rssi_thold = default_match_rssi;
  891. +
  892. + request->min_rssi_thold = INT_MAX;
  893. + for (i = 0; i < n_match_sets; i++)
  894. + request->min_rssi_thold =
  895. + min(request->match_sets[i].rssi_thold,
  896. + request->min_rssi_thold);
  897. + } else {
  898. + request->min_rssi_thold = NL80211_SCAN_RSSI_THOLD_OFF;
  899. }
  900. if (info->attrs[NL80211_ATTR_IE]) {
  901. @@ -7502,16 +7561,19 @@ static int nl80211_set_tx_bitrate_mask(s
  902. * directly to the enum ieee80211_band values used in cfg80211.
  903. */
  904. BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
  905. - nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem)
  906. - {
  907. + nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) {
  908. enum ieee80211_band band = nla_type(tx_rates);
  909. + int err;
  910. +
  911. if (band < 0 || band >= IEEE80211_NUM_BANDS)
  912. return -EINVAL;
  913. sband = rdev->wiphy.bands[band];
  914. if (sband == NULL)
  915. return -EINVAL;
  916. - nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
  917. - nla_len(tx_rates), nl80211_txattr_policy);
  918. + err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
  919. + nla_len(tx_rates), nl80211_txattr_policy);
  920. + if (err)
  921. + return err;
  922. if (tb[NL80211_TXRATE_LEGACY]) {
  923. mask.control[band].legacy = rateset_to_mask(
  924. sband,
  925. @@ -10054,40 +10116,31 @@ void nl80211_send_scan_start(struct cfg8
  926. NL80211_MCGRP_SCAN, GFP_KERNEL);
  927. }
  928. -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
  929. - struct wireless_dev *wdev)
  930. +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
  931. + struct wireless_dev *wdev, bool aborted)
  932. {
  933. struct sk_buff *msg;
  934. msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  935. if (!msg)
  936. - return;
  937. + return NULL;
  938. if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
  939. - NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
  940. + aborted ? NL80211_CMD_SCAN_ABORTED :
  941. + NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
  942. nlmsg_free(msg);
  943. - return;
  944. + return NULL;
  945. }
  946. - genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
  947. - NL80211_MCGRP_SCAN, GFP_KERNEL);
  948. + return msg;
  949. }
  950. -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
  951. - struct wireless_dev *wdev)
  952. +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
  953. + struct sk_buff *msg)
  954. {
  955. - struct sk_buff *msg;
  956. -
  957. - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  958. if (!msg)
  959. return;
  960. - if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
  961. - NL80211_CMD_SCAN_ABORTED) < 0) {
  962. - nlmsg_free(msg);
  963. - return;
  964. - }
  965. -
  966. genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
  967. NL80211_MCGRP_SCAN, GFP_KERNEL);
  968. }
  969. @@ -11673,6 +11726,35 @@ void cfg80211_crit_proto_stopped(struct
  970. }
  971. EXPORT_SYMBOL(cfg80211_crit_proto_stopped);
  972. +void nl80211_send_ap_stopped(struct wireless_dev *wdev)
  973. +{
  974. + struct wiphy *wiphy = wdev->wiphy;
  975. + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  976. + struct sk_buff *msg;
  977. + void *hdr;
  978. +
  979. + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  980. + if (!msg)
  981. + return;
  982. +
  983. + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_STOP_AP);
  984. + if (!hdr)
  985. + goto out;
  986. +
  987. + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
  988. + nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex) ||
  989. + nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
  990. + goto out;
  991. +
  992. + genlmsg_end(msg, hdr);
  993. +
  994. + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(wiphy), msg, 0,
  995. + NL80211_MCGRP_MLME, GFP_KERNEL);
  996. + return;
  997. + out:
  998. + nlmsg_free(msg);
  999. +}
  1000. +
  1001. /* initialisation/exit functions */
  1002. int nl80211_init(void)
  1003. --- a/net/wireless/nl80211.h
  1004. +++ b/net/wireless/nl80211.h
  1005. @@ -8,10 +8,10 @@ void nl80211_exit(void);
  1006. void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
  1007. void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
  1008. struct wireless_dev *wdev);
  1009. -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
  1010. - struct wireless_dev *wdev);
  1011. -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
  1012. - struct wireless_dev *wdev);
  1013. +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
  1014. + struct wireless_dev *wdev, bool aborted);
  1015. +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
  1016. + struct sk_buff *msg);
  1017. void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
  1018. struct net_device *netdev, u32 cmd);
  1019. void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
  1020. @@ -74,6 +74,8 @@ nl80211_radar_notify(struct cfg80211_reg
  1021. enum nl80211_radar_event event,
  1022. struct net_device *netdev, gfp_t gfp);
  1023. +void nl80211_send_ap_stopped(struct wireless_dev *wdev);
  1024. +
  1025. void cfg80211_rdev_free_coalesce(struct cfg80211_registered_device *rdev);
  1026. #endif /* __NET_WIRELESS_NL80211_H */
  1027. --- a/net/wireless/scan.c
  1028. +++ b/net/wireless/scan.c
  1029. @@ -161,18 +161,25 @@ static void __cfg80211_bss_expire(struct
  1030. dev->bss_generation++;
  1031. }
  1032. -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev)
  1033. +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
  1034. + bool send_message)
  1035. {
  1036. struct cfg80211_scan_request *request;
  1037. struct wireless_dev *wdev;
  1038. + struct sk_buff *msg;
  1039. #ifdef CPTCFG_CFG80211_WEXT
  1040. union iwreq_data wrqu;
  1041. #endif
  1042. ASSERT_RTNL();
  1043. - request = rdev->scan_req;
  1044. + if (rdev->scan_msg) {
  1045. + nl80211_send_scan_result(rdev, rdev->scan_msg);
  1046. + rdev->scan_msg = NULL;
  1047. + return;
  1048. + }
  1049. + request = rdev->scan_req;
  1050. if (!request)
  1051. return;
  1052. @@ -186,18 +193,16 @@ void ___cfg80211_scan_done(struct cfg802
  1053. if (wdev->netdev)
  1054. cfg80211_sme_scan_done(wdev->netdev);
  1055. - if (request->aborted) {
  1056. - nl80211_send_scan_aborted(rdev, wdev);
  1057. - } else {
  1058. - if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
  1059. - /* flush entries from previous scans */
  1060. - spin_lock_bh(&rdev->bss_lock);
  1061. - __cfg80211_bss_expire(rdev, request->scan_start);
  1062. - spin_unlock_bh(&rdev->bss_lock);
  1063. - }
  1064. - nl80211_send_scan_done(rdev, wdev);
  1065. + if (!request->aborted &&
  1066. + request->flags & NL80211_SCAN_FLAG_FLUSH) {
  1067. + /* flush entries from previous scans */
  1068. + spin_lock_bh(&rdev->bss_lock);
  1069. + __cfg80211_bss_expire(rdev, request->scan_start);
  1070. + spin_unlock_bh(&rdev->bss_lock);
  1071. }
  1072. + msg = nl80211_build_scan_msg(rdev, wdev, request->aborted);
  1073. +
  1074. #ifdef CPTCFG_CFG80211_WEXT
  1075. if (wdev->netdev && !request->aborted) {
  1076. memset(&wrqu, 0, sizeof(wrqu));
  1077. @@ -211,6 +216,11 @@ void ___cfg80211_scan_done(struct cfg802
  1078. rdev->scan_req = NULL;
  1079. kfree(request);
  1080. +
  1081. + if (!send_message)
  1082. + rdev->scan_msg = msg;
  1083. + else
  1084. + nl80211_send_scan_result(rdev, msg);
  1085. }
  1086. void __cfg80211_scan_done(struct work_struct *wk)
  1087. @@ -221,7 +231,7 @@ void __cfg80211_scan_done(struct work_st
  1088. scan_done_wk);
  1089. rtnl_lock();
  1090. - ___cfg80211_scan_done(rdev);
  1091. + ___cfg80211_scan_done(rdev, true);
  1092. rtnl_unlock();
  1093. }
  1094. @@ -1079,7 +1089,7 @@ int cfg80211_wext_siwscan(struct net_dev
  1095. if (IS_ERR(rdev))
  1096. return PTR_ERR(rdev);
  1097. - if (rdev->scan_req) {
  1098. + if (rdev->scan_req || rdev->scan_msg) {
  1099. err = -EBUSY;
  1100. goto out;
  1101. }
  1102. @@ -1481,7 +1491,7 @@ int cfg80211_wext_giwscan(struct net_dev
  1103. if (IS_ERR(rdev))
  1104. return PTR_ERR(rdev);
  1105. - if (rdev->scan_req)
  1106. + if (rdev->scan_req || rdev->scan_msg)
  1107. return -EAGAIN;
  1108. res = ieee80211_scan_results(rdev, info, extra, data->length);
  1109. --- a/net/wireless/sme.c
  1110. +++ b/net/wireless/sme.c
  1111. @@ -67,7 +67,7 @@ static int cfg80211_conn_scan(struct wir
  1112. ASSERT_RDEV_LOCK(rdev);
  1113. ASSERT_WDEV_LOCK(wdev);
  1114. - if (rdev->scan_req)
  1115. + if (rdev->scan_req || rdev->scan_msg)
  1116. return -EBUSY;
  1117. if (wdev->conn->params.channel)