]> git.ipfire.org Git - thirdparty/hostap.git/log
thirdparty/hostap.git
7 years agoAdd support to sched scan to report relatively better BSSs
vamsi krishna [Tue, 15 Nov 2016 09:42:44 +0000 (15:12 +0530)] 
Add support to sched scan to report relatively better BSSs

Add support to set sched scan relative RSSI parameters so that the
drivers can report BSSs after relative comparision with the current
connected BSS. This feature is applicable only when in connected mode.

The below commands can be used to configure relative RSSI parameters
SET relative_rssi <disable|rssi_value>
disable - to disable the feature
rssi_value - amount of relative RSSI in dB
SET relative_band_adjust <band:adjust_value>
band - "2G" or "5G" for 2.4 GHz or 5 GHz respectively
adjust_value - amount of RSSI to be adjusted in dB

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agonl80211: sched_scan relative RSSI parameters
vamsi krishna [Tue, 15 Nov 2016 09:42:44 +0000 (15:12 +0530)] 
nl80211: sched_scan relative RSSI parameters

Add driver interface support to set sched_scan relative RSSI parameters
and to indicate driver support for this.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agomka: Send MKPDUs forever if mode is PSK
Badrish Adiga H R [Tue, 7 Feb 2017 08:58:31 +0000 (14:28 +0530)] 
mka: Send MKPDUs forever if mode is PSK

Issue: When 2 peers are running MACsec in PSK mode with CA
established, if the interface goes down and comes up after
time > 10 seconds, CA does not get re-established.

Root cause: This is because retry_count of both the peers
would have reached MAX_RETRY_CNT and stays idle for other to
respond. This is clear deadlock situation where peer A waits
for MKA packets from peer B to wake up and vice-versa.

Fix: If MACsec is running in PSK mode, we should send MKPDUs
forever for every 2 seconds.

Signed-off-by: Badrish Adiga H R <badrish.adigahr@gmail.com>
7 years agotests: EAP-AKA within EAP-TTLS/PEAP/FAST tunnel and reauth
Jouni Malinen [Fri, 10 Feb 2017 16:56:30 +0000 (18:56 +0200)] 
tests: EAP-AKA within EAP-TTLS/PEAP/FAST tunnel and reauth

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoEAP: Call deinit_for_reauth() for Phase 2 EAP methods
Jouni Malinen [Fri, 10 Feb 2017 16:55:26 +0000 (18:55 +0200)] 
EAP: Call deinit_for_reauth() for Phase 2 EAP methods

EAP-TTLS/PEAP/FAST were previously doing this for init_for_reauth(), but
not for deinit_for_reauth(). Add the deinit_for_reauth() call as well to
cover cases like EAP-AKA cleaup of AT_CHECKCODE data.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoEAP-AKA: Don't use anonymous identity in phase2
Jouni Malinen [Fri, 10 Feb 2017 16:54:20 +0000 (18:54 +0200)] 
EAP-AKA: Don't use anonymous identity in phase2

This adds the same changes to EAP-AKA that were previous done for
EAP-SIM to allow functionality within an EAP-TTLS/PEAP/FAST tunnel
without causing issues to the phase 1 identity string.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: EAP-SIM tunneled within EAP-TTLS/PEAP/FAST
Jouni Malinen [Fri, 10 Feb 2017 14:05:33 +0000 (16:05 +0200)] 
tests: EAP-SIM tunneled within EAP-TTLS/PEAP/FAST

This verifies both the internal and external GSM authentication
operation when EAP-SIM is tunneled within EAP-TTLS/PEAP/FAST.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoEAP-SIM: Don't use anonymous identity in phase2
Paul Stewart [Thu, 9 Feb 2017 01:47:57 +0000 (17:47 -0800)] 
EAP-SIM: Don't use anonymous identity in phase2

The "anonymous_identity" configuration field has more than one
semantic meaning. For tunneled EAP methods, this refers to the
outer EAP identity. For EAP-SIM, this refers to the pseudonym
identity. Also, interestingly, EAP-SIM can overwrite the
"anonymous_identity" field if one is provided to it by the
authenticator.

When EAP-SIM is tunneled within an outer method, it makes sense
to only use this value for the outer method, since it's unlikely
that this will also be valid as an identity for the inner EAP-SIM
method. Also, presumably since the outer method protects the
EAP-SIM transaction, there is no need for a pseudonym in this
usage.

Similarly, if EAP-SIM is being used as an inner method, it must
not push the pseudonym identity using eap_set_anon_id() since it
could overwrite the identity for the outer EAP method.

Signed-off-by: Paul Stewart <pstew@google.com>
7 years agoEAP peer: Cache decrypted requests for EAP-SIM/AKA/AKA'
Paul Stewart [Thu, 9 Feb 2017 00:46:41 +0000 (16:46 -0800)] 
EAP peer: Cache decrypted requests for EAP-SIM/AKA/AKA'

Add an internal flag which indicates to tunneled EAP methods (FAST,
PEAP, TTLS) that they should cache decrypted EAP-SIM/AKA/AKA' requests.
This allows EAP-SIM/AKA/AKA' to be tunneled within these outer methods
while using an external SIM authenticator over the control interface.

Signed-off-by: Paul Stewart <pstew@google.com>
7 years agotests: WPA-PSK/TKIP countermeasures (detected by two STAs)
Jouni Malinen [Fri, 10 Feb 2017 09:51:00 +0000 (11:51 +0200)] 
tests: WPA-PSK/TKIP countermeasures (detected by two STAs)

This includes check for hostapd ending TKIP countermeasures.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoSME: Remove null ie param from CTRL-EVENT-AUTH-REJECT
Jouni Malinen [Fri, 10 Feb 2017 09:49:36 +0000 (11:49 +0200)] 
SME: Remove null ie param from CTRL-EVENT-AUTH-REJECT

Clean up the event message by removing the ie=<value> parameter when the
IEs are not available instead of printing out "ie=(null)".

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: Additional RRM testing coverage for hostapd
Jouni Malinen [Thu, 9 Feb 2017 10:27:30 +0000 (12:27 +0200)] 
tests: Additional RRM testing coverage for hostapd

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoRRM: Fix a memory leak in beacon request handling
Jouni Malinen [Thu, 9 Feb 2017 14:54:26 +0000 (16:54 +0200)] 
RRM: Fix a memory leak in beacon request handling

Free the pending frequency list if a second beacon request is received
before the scan for the previous one has been completed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoRRM: Fix range request overriding
Jouni Malinen [Thu, 9 Feb 2017 11:25:29 +0000 (13:25 +0200)] 
RRM: Fix range request overriding

This was supposed to cancel the existing eloop timeout instead of
registering another one.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoRRM: Merge similar error returns to a single one
Jouni Malinen [Thu, 9 Feb 2017 11:24:26 +0000 (13:24 +0200)] 
RRM: Merge similar error returns to a single one

There is no need to maintain different return paths for STA being
completely not present and not authorized, so merge these into a single
case.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoRRM: Fix Range Request max age parsing
Jouni Malinen [Thu, 9 Feb 2017 11:23:00 +0000 (13:23 +0200)] 
RRM: Fix Range Request max age parsing

This 16-bit field uses little endian encoding and it must be read with
WPA_GET_LE16() instead of assuming host byte order is little endian. In
addition, this could be misaligned, so using a u16 pointer here was not
appropriate.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: More WPA2 PSK from RADIUS Tunnel-Password coverage
Jouni Malinen [Wed, 8 Feb 2017 18:15:10 +0000 (20:15 +0200)] 
tests: More WPA2 PSK from RADIUS Tunnel-Password coverage

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: RADIUS MAC ACL and server unreachable
Jouni Malinen [Wed, 8 Feb 2017 15:41:21 +0000 (17:41 +0200)] 
tests: RADIUS MAC ACL and server unreachable

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoFix MAC ACL query freeing on deinit
Jouni Malinen [Wed, 8 Feb 2017 15:37:50 +0000 (17:37 +0200)] 
Fix MAC ACL query freeing on deinit

hapd->acl_cache and hapd->acl_queries were not reset back to NULL in
hostapd_acl_deinit() when cached results and pending ACL queries were
freed. This left stale pointers to freed memory in hapd. While this was
normally followed by freeing of the hapd data, it is possible to re-use
that hapd when disabling and re-enabling an interface. That sequence
could result in use of freed memory if done while there were cached
results or pending ACL operations with a RADIUS server (especially, if
that server did not reply).

Fix this by setting hapd->acl_queries to NULL when the pending entries
are freed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: RADIUS MAC ACL and OOM
Jouni Malinen [Wed, 8 Feb 2017 15:28:49 +0000 (17:28 +0200)] 
tests: RADIUS MAC ACL and OOM

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: RADIUS Accounting in RSN and failure to add attributes due to OOM
Jouni Malinen [Wed, 8 Feb 2017 14:16:21 +0000 (16:16 +0200)] 
tests: RADIUS Accounting in RSN and failure to add attributes due to OOM

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoAllow PNO scan also in connection completed state
vamsi krishna [Wed, 8 Feb 2017 12:10:34 +0000 (17:40 +0530)] 
Allow PNO scan also in connection completed state

Sched scan is supported by the kernel also in the connected state, so
allow PNO scan to be issued in the connected state from wpa_supplicant
as well.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: Make ap_wps_er_http_proto less likely to fail
Jouni Malinen [Wed, 8 Feb 2017 11:53:11 +0000 (13:53 +0200)] 
tests: Make ap_wps_er_http_proto less likely to fail

The test step for concurrent HTTP connections seems to be failing quite
frequently when running in a virtual machine with run-tests.py (but not
that much with kvm and vm-run.sh). The failures are due to only 8 or 9
sockets getting a response from the HTTP server. This is sufficient for
testing purposes, to drop the pass criterium from 10 to 8 concurrent
connections. This avoids unnecessary test failures and also allows the
rest of the test case to be performed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: Check for ebtables having been installed
Jouni Malinen [Wed, 8 Feb 2017 11:35:36 +0000 (13:35 +0200)] 
tests: Check for ebtables having been installed

This makes proxyarp_open_ebtables and proxyarp_open_ebtables_ipv6 return
SKIP cleanly if the ebtables binary is not installed or does not work.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoAdd radio_work_is_connect() helper
Jouni Malinen [Tue, 7 Feb 2017 21:55:48 +0000 (23:55 +0200)] 
Add radio_work_is_connect() helper

This avoids duplicated code to check for different types of connection
radio work items.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoSerialize scan/p2p-scan if already scheduled on the same interface
Sunil Dutt [Thu, 2 Feb 2017 12:49:45 +0000 (18:19 +0530)] 
Serialize scan/p2p-scan if already scheduled on the same interface

The current implementation of QCA vendor scan does not handle the
simultaneous scan/p2p-scan operations on the same interface due to
missing support for tracking multiple scan cookie values. Hence
serialize such operations on the same interface for now.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: Make radius_acct_interim more robust
Jouni Malinen [Tue, 7 Feb 2017 21:07:04 +0000 (23:07 +0200)] 
tests: Make radius_acct_interim more robust

Wait one more second to make the test case less likely to fail while
still being able to verify that interim updates are performed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: Clear country code at the end of wpas_config_file
Jouni Malinen [Tue, 7 Feb 2017 21:03:35 +0000 (23:03 +0200)] 
tests: Clear country code at the end of wpas_config_file

This test case was mistakenly leaving the country code FI configured at
the end which could result in issues with the following test cases. Fix
this by explicitly clearing the country code back to world roaming 00 at
the end of wpas_config_file.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoP2P: Clear driver scan cache after BSS_FLUSH
Jouni Malinen [Tue, 7 Feb 2017 20:48:20 +0000 (22:48 +0200)] 
P2P: Clear driver scan cache after BSS_FLUSH

The only_new_results=1 scan parameter was previously set on other scan
cases, but not on the two P2P specific scan triggers. Set this also for
those P2P cases to get consistent behavior after BSS_FLUSH.

This was showing up with number of hwsim P2P test cases maintaining
unexpected scan results from previous test cases due to the flush
operation not really working correctly since the cfg80211 BSS table was
not explicitly cleared.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoFILS: Clean up HLP resize check
Jouni Malinen [Tue, 7 Feb 2017 18:50:33 +0000 (20:50 +0200)] 
FILS: Clean up HLP resize check

The "!wpabuf_resize(...) == 0" condition does not make any sense. It
happens to work, but this is really supposed to simple check with
wpabuf_resize() returns non-zero and "wpabuf_resize(...)" is the
cleanest way of doing so.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: Verify GAS/ANQP transmitter address randomization
Vamsi Krishna [Thu, 8 Dec 2016 16:23:40 +0000 (21:53 +0530)] 
tests: Verify GAS/ANQP transmitter address randomization

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoGAS: Add support to randomize transmitter address
Vamsi Krishna [Thu, 8 Dec 2016 16:21:25 +0000 (21:51 +0530)] 
GAS: Add support to randomize transmitter address

Add support to send GAS requests with a randomized transmitter address
if supported by the driver. The following control interface commands
(and matching configuration file parameters) can be used to configure
different types of randomization:

"SET gas_rand_mac_addr 0" to disable randomizing TX MAC address,
"SET gas_rand_mac_addr 1" to randomize the complete TX MAC address,
"SET gas_rand_mac_addr 2" to randomize the TX MAC address except for OUI.

A new random MAC address will be generated for every
gas_rand_addr_lifetime seconds and this can be configured with
"SET gas_rand_addr_lifetime <timeout>".

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agonl80211: Add support for mgmt_tx with random TA
Vamsi Krishna [Thu, 8 Dec 2016 16:21:25 +0000 (21:51 +0530)] 
nl80211: Add support for mgmt_tx with random TA

This adds support for specifying a random TA for management frame
transmission commands and driver capability flags for indicating whether
this is supported in not-connected and connected states.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoSync with mac80211-next.git include/uapi/linux/nl80211.h
Jouni Malinen [Tue, 7 Feb 2017 16:55:35 +0000 (18:55 +0200)] 
Sync with mac80211-next.git include/uapi/linux/nl80211.h

This brings in nl80211 definitions as of 2017-01-13.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agotests: Additional GAS server coverage
Jouni Malinen [Tue, 7 Feb 2017 13:46:20 +0000 (15:46 +0200)] 
tests: Additional GAS server coverage

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoGAS: Fix OSU Providers List response with invalid configuration
Jouni Malinen [Tue, 7 Feb 2017 15:46:29 +0000 (17:46 +0200)] 
GAS: Fix OSU Providers List response with invalid configuration

If the OSU Providers configuration was invalid (included osu_server_uri
but not osu_method_list), it was possible for the GAS response
generation to hit a NULL dereference. Fix this by checking for the
invalid configuration before trying to fill in the OSU methods.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: wpa_supplicant AP mode - 5 GHz
Jouni Malinen [Tue, 7 Feb 2017 09:22:29 +0000 (11:22 +0200)] 
tests: wpa_supplicant AP mode - 5 GHz

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoVHT: Fill VHT capability with hardware capability
Masashi Honma [Tue, 7 Feb 2017 02:50:57 +0000 (11:50 +0900)] 
VHT: Fill VHT capability with hardware capability

Previously, VHT capability was default value (=0x0000). This makes
VHT Capabilities Info in VHT Capabilities IE in mesh peering
open/confirm frame 0x0000. This patch fills it with hardware capability.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
7 years agotests: Make go_search_non_social more robust
Jouni Malinen [Tue, 7 Feb 2017 09:08:24 +0000 (11:08 +0200)] 
tests: Make go_search_non_social more robust

Try the initial scan on the operating channel twice before claiming a
test failure. It is possible for an active scan to fail to see the GO
especially if running the test under heavy load.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: WPA2-PSK EAPOL-Key retry limit configuration
Jouni Malinen [Mon, 6 Feb 2017 21:59:41 +0000 (23:59 +0200)] 
tests: WPA2-PSK EAPOL-Key retry limit configuration

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoAdd a log message when GTK rekeying failed
Günther Kelleter [Mon, 6 Feb 2017 21:55:42 +0000 (23:55 +0200)] 
Add a log message when GTK rekeying failed

It can happen if the station is unreachable or sleeping longer than
the actual total GTK rekey timeout. To fix the latter case
wpa_group_update_count may be increased.

Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>
7 years agoAdd hostapd options wpa_group_update_count and wpa_pairwise_update_count
Günther Kelleter [Thu, 5 Jan 2017 16:00:33 +0000 (17:00 +0100)] 
Add hostapd options wpa_group_update_count and wpa_pairwise_update_count

wpa_group_update_count and wpa_pairwise_update_count can now be used to
set the GTK and PTK rekey retry limits (dot11RSNAConfigGroupUpdateCount
and dot11RSNAConfigPairwiseUpdateCount). Defaults set to current
hardcoded value (4).

Some stations may suffer from frequent deauthentications due to GTK
rekey failures: EAPOL 1/2 frame is not answered during the total timeout
period of currently ~3.5 seconds. For example, a Galaxy S6 with Android
6.0.1 appears to go into power save mode for up to 5 seconds. Increasing
wpa_group_update_count to 6 fixed this issue.

Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>
7 years agomka: Some bug fixes for MACsec in PSK mode
Badrish Adiga H R [Fri, 6 Jan 2017 09:57:10 +0000 (15:27 +0530)] 
mka: Some bug fixes for MACsec in PSK mode

Issue:
------
The test setup has 2 peers running MACsec in PSK mode, Peer A with
MAC address higher than MAC Address of peer B. Test sequence is
1. Peer B starts with actor_priority 255
2. Peer A starts with priority 16, becomes key server.
3. Peer A stops..
4. Peer A restarts with priority 255, but because of the stale values
participant->is_key_server(=TRUE) and participant->is_elected(=TRUE)
it continues to remain as Key Server.
5. For peer B, key server election happens and since it has lower MAC
address as compared to MAC address of A, it becomes the key server.
Now we have 2 key servers in CA and is not correct.

Root-cause & fix:
-----------------
When number of live peers become 0, the flags such lrx, ltx, orx,
otx, etc. need to be cleared. In MACsec PSK mode, these stale values
create problems while re-establishing CA.

Signed-off-by: Badrish Adiga H R <badrish.adigahr@gmail.com>
7 years agomka: Fix an incorrect update of participant->to_use_sak
Badrish Adiga H R [Fri, 6 Jan 2017 12:17:51 +0000 (17:47 +0530)] 
mka: Fix an incorrect update of participant->to_use_sak

API ieee802_1x_mka_decode_dist_sak_body() wrongly puts
participant->to_use_sak to TRUE, if Distributed SAK Parameter Set of
length 0 is received. In MACsec PSK mode, this stale incorrect value can
create problems while re-establishing CA. In MACsec PSK mode, CA goes
down if interface goes down and ideally we should be able to
re-establish the CA once interface comes up.

Signed-off-by: Badrish Adiga H R <badrish.adigahr@gmail.com>
7 years agohs20-osu-client: Hide a trivial compiler warning
Masashi Honma [Mon, 6 Feb 2017 11:07:44 +0000 (20:07 +0900)] 
hs20-osu-client: Hide a trivial compiler warning

This patch hides a compiler warning:

osu_client.c: In function â€˜cmd_osu_select’:
osu_client.c:2200:2: warning: â€˜osu_count’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  for (i = 0; i < osu_count; i++) {
  ^

osu_count is actually initialized in parse_osu_providers() if non-NULL
value is returned.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
7 years agotests: VHT and 40 MHz channel configuration falling back to 20 MHz
Jouni Malinen [Mon, 6 Feb 2017 17:22:47 +0000 (19:22 +0200)] 
tests: VHT and 40 MHz channel configuration falling back to 20 MHz

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agohw_features: Clean center freq for falling back HT40 channels
Eduardo Abinader [Tue, 17 Jan 2017 10:59:03 +0000 (11:59 +0100)] 
hw_features: Clean center freq for falling back HT40 channels

Some channels fail to be set, when falling back to 20 MHz, due to
remaining VHT info of center freq. As we are going to 20 MHz, reset the
VHT center frequency segment information as well.

Signed-off-by: Eduardo Abinader <eduardoabinader@gmail.com>
7 years agoP2P: Override P2P_PEER group_capab with 0 if no matching BSS entry found
Sunil Dutt [Tue, 31 Jan 2017 18:57:06 +0000 (00:27 +0530)] 
P2P: Override P2P_PEER group_capab with 0 if no matching BSS entry found

Relying on the group_capab from the P2P peer information can result in
improper information on whether the peer is currently operating as a GO.
However, there is a known implementation in Android that does this.

To reduce issues from this misuse in upper layer to try to determine
whether a specific peer is operationg a group, override the group_capab
value in P2P_PEER output with 0 if there are no BSS entries with the
peer P2P Device as a GO. This is not a perfect information since there
may not have been a recent scan on all channels, but this results in
less issues than trying to decide between new group formation and
joining an existing group based on stale or incorrect information.

Since no upper layer application is really supposed to use the
group_capab field value in P2P_PEER command, this change should not
cause any impact for properly design components and the possibility of
regressions is limited to cases that are already known to work
incorrectly in number of identifiable cases.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoFix estimated throughput based skip-roam case
Jouni Malinen [Sun, 5 Feb 2017 19:52:26 +0000 (21:52 +0200)] 
Fix estimated throughput based skip-roam case

Commit 8d1e693186336f85bf5d86bd094b5c9bd6f8fd02 ('Use estimated
throughput to avoid signal based roaming decision') added a check for
the current BSS estimated throughput being significantly higher than the
selected BSS estimated throughput. However, this case for skipping a
roam used "return 1" which actually allows the roam. Fix this by
returning 0 in this case.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agonl80211: Fix error while enabling AP mode with driver-SME
Dedy Lansky [Sun, 5 Feb 2017 10:52:09 +0000 (12:52 +0200)] 
nl80211: Fix error while enabling AP mode with driver-SME

Following commit a70cd0db876b2ffad7e3d608e3f9a2fcf2e7a879 ('Don't
register for Beacon frames for IEEE 802.11ad AP'),
nl80211_get_wiphy_data_ap() is unconditionally called when starting AP.
This function tries to register for Beacon frames RX which fails for
some driver which don't support such registration and do not need it in
case the driver implements AP mode SME functionality.

Fix this by conditionally calling nl80211_get_wiphy_data_ap() like prior
to commit a70cd0db876b2ffad7e3d608e3f9a2fcf2e7a879.

Signed-off-by: Dedy Lansky <qca_dlansky@qca.qualcomm.com>
7 years agotests: RADIUS Accounting local failure cases
Jouni Malinen [Sun, 5 Feb 2017 15:11:29 +0000 (17:11 +0200)] 
tests: RADIUS Accounting local failure cases

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agotests: BSS Load update failing to get survey data
Jouni Malinen [Sun, 5 Feb 2017 14:52:38 +0000 (16:52 +0200)] 
tests: BSS Load update failing to get survey data

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoFILS: Fix send_assoc_resp() HLP extension to cover sta == NULL
Jouni Malinen [Sun, 5 Feb 2017 14:40:15 +0000 (16:40 +0200)] 
FILS: Fix send_assoc_resp() HLP extension to cover sta == NULL

Commit 91d91abf6f9bf420643a9245b63f5ac8c6bbb18a ('FILS: DHCP relay for
HLP requests') added steps that are conditional on sta->fils_hlp_resp
being non-NULL. One of these cases within send_assoc_resp() was properly
protected from sta == NULL error case (that is now possible after a
recent DMG change), but the first one was not. A DMG error case in a
CONFIG_FILS=y build could have hit a NULL pointer dereference here. Fix
this by verifying sta != NULL more consistently.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agotests: Validate hwaddr/hexstr input to DRIVER_EVENT SCAN_RES
Jouni Malinen [Sun, 5 Feb 2017 14:31:03 +0000 (16:31 +0200)] 
tests: Validate hwaddr/hexstr input to DRIVER_EVENT SCAN_RES

To be more consistent with existing hwaddr_aton() and hexstr2bin()
callers, check the return values in this test command.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoFILS: Stop processing if fils_rmsk_to_pmk() fails
Jouni Malinen [Sun, 5 Feb 2017 12:38:07 +0000 (14:38 +0200)] 
FILS: Stop processing if fils_rmsk_to_pmk() fails

While the key derivation steps are not expected to fail, this was
already done on the AP side, so do the same in the STA side.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoSet EAPOL-Key Key Length field to 0 for group message 1/2 in RSN
Jouni Malinen [Sun, 5 Feb 2017 11:52:43 +0000 (13:52 +0200)] 
Set EAPOL-Key Key Length field to 0 for group message 1/2 in RSN

P802.11i/D3.0 described the Key Length as having value 16 for the group
key handshake. However, this was changed to 0 in the published IEEE Std
802.11i-2004 amendment (and still remains 0 in the current standard IEEE
Std 802.11-2016). We need to maintain the non-zero value for WPA (v1)
cases, but the RSN case can be changed to 0 to be closer to the current
standard.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoDo not send GNonce in EAPOL-Key group message 1/2
Jouni Malinen [Sun, 5 Feb 2017 11:39:57 +0000 (13:39 +0200)] 
Do not send GNonce in EAPOL-Key group message 1/2

While the IEEE Std 802.11-2016 is still indicating that GNonce would be
exchanged in EAPOL-Key messages (see, e.g., Figure 12-52 showing the
Send EAPOL-Key operation in the REKEYNEGOTIATING state or the sample
group key handshake in Figure 12-47), there are also examples of
describing this field as having value zero (e.g., 12.7.7.2 Group key
handshake message 1).

GNonce is used only with the Authenticator and the Supplicant does not
have any use for it, so it is better not to expose that internal value.
Hardcode the Key Nonce field to 0 in EAPOL-Key group message 1/2.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoFix EAPOL-Key Install bit in Group Key 1/2 with FT and FILS auth
Jouni Malinen [Sun, 5 Feb 2017 11:28:42 +0000 (13:28 +0200)] 
Fix EAPOL-Key Install bit in Group Key 1/2 with FT and FILS auth

sm->Pair needs to be initialized to TRUE since unicast cipher is
supported and this is an ESS. However, the normal place for setting this
(WPA_PTK::INITIALIZE) is skipped with using FT protocol or FILS
authentication, so need to do that separately when forcing PTKINITDONE.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agotests: Update mesh_oom to match the wpa_supplicant_mesh_init() change
Jouni Malinen [Sat, 4 Feb 2017 20:46:06 +0000 (22:46 +0200)] 
tests: Update mesh_oom to match the wpa_supplicant_mesh_init() change

There is now one fewer direct allocation call in this function, so the
counters need to be updated to avoid test failures.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agomesh: Fix struct hostapd_data initialization
Jouni Malinen [Sat, 4 Feb 2017 20:17:54 +0000 (22:17 +0200)] 
mesh: Fix struct hostapd_data initialization

The local custom version of allocating and initializing struct
hostapd_data within wpa_supplicant_mesh_init() is problematic. This has
already missed couple of initialization steps that are required. Instead
of trying to remember to keep this up to date, use
hostapd_alloc_bss_data() so that there is only one place for this
initialization.

This is fixing a recent issue where FILS HLP started using
hapd->dhcp_server and expected that to be initialized to -1. For the
mesh case, that did not happen and when removing the interface, the FILS
HLP implementation ended up unregistering eloop socket for
hapd->dhcp_server (= 0). This could result in missing socket callbacks
for an arbitrary socket.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agomesh: Fix mesh interface removal fix
Jouni Malinen [Sat, 4 Feb 2017 19:24:37 +0000 (21:24 +0200)] 
mesh: Fix mesh interface removal fix

This wpa_drv_if_remove() call was previously modified to fix a different
issue, but that fix resulted in unconditional use of treed memory here
(wpa_supplicant_deinit_iface() frees wpa_s). Make a local copy of
wpa_s->parent to be able to use it after wpa_s is freed. The
mesh_if_created case has wpa_s->parent != wpa_s, so this should be
sufficient way of handling the wpa_drv_if_remove() call here.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoUpdate wpaspy.py to be python3 compatible
Preston Hunt [Tue, 31 Jan 2017 01:25:03 +0000 (01:25 +0000)] 
Update wpaspy.py to be python3 compatible

Make minor changes to wpaspy module that enables it to run in either
python2 or python3.

Signed-off-by: Preston Hunt <preston.hunt@intel.com>
7 years agoUse defines in hostapd_set_freq_params()
Jouni Malinen [Sat, 4 Feb 2017 18:50:16 +0000 (20:50 +0200)] 
Use defines in hostapd_set_freq_params()

Use the defines for vht_oper_chwidth values more consistently in
hostapd_set_freq_params() to make this more readable.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoeloop: Fix comments mismatch eloop_event/timeout_handler definitions
Liu Li [Sat, 4 Feb 2017 04:13:48 +0000 (12:13 +0800)] 
eloop: Fix comments mismatch eloop_event/timeout_handler definitions

Signed-off-by: Liu Li <lli_njupt@163.com>
7 years agoUpdate the copyright notice years for QCA vendor definitions
Jouni Malinen [Sat, 4 Feb 2017 15:05:30 +0000 (17:05 +0200)] 
Update the copyright notice years for QCA vendor definitions

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoQCA vendor command to set the trace levels for the specific QCA module
Sunil Dutt [Tue, 31 Jan 2017 05:58:54 +0000 (11:28 +0530)] 
QCA vendor command to set the trace levels for the specific QCA module

This commit introduces the vendor command to set the trace level
for the respective QCA host driver module.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoFILS: Fix AES-SIV AAD for (Re)Association Request frame decryption
Jouni Malinen [Sat, 4 Feb 2017 11:05:58 +0000 (13:05 +0200)] 
FILS: Fix AES-SIV AAD for (Re)Association Request frame decryption

The hostapd processing of the AES-SIV AAD was incorrect. The design for
the AAD changed between P802.11ai/D7.0 and D8.0 from a single vector
with concatenated data to separate vectors. The change in the
implementation had missed the change in the aes_siv_decrypt() call for
the num_elem parameter. This happened to work with the mac80211
implementation due to a similar error there.

Fix this by using the correct numbers of vectors in the SIV AAD so that
all the vectors get checked. The last vector was also 14 octets too long
due to incorrect starting pointer, so fix that as well. The changes here
are not backwards compatible, i.e., a similar fix in the Linux mac80211
is needed to make things interoperate again.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoERP: Use macro for EMSKname length instead of hardcoded integer value
Jouni Malinen [Fri, 3 Feb 2017 12:41:39 +0000 (14:41 +0200)] 
ERP: Use macro for EMSKname length instead of hardcoded integer value

While RFC 5295 uses "8" as the value to use in the length field in KDF
context when deriving EMSKname, it is clearer to use the macro defining
EMSKname as the value since the KDF design in RFC 5295 encodes the
length of the derived data in octets in that part of the context data.
This change is just making the implementation easier to understand while
not actually changing the behavior.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoERP: Fix rIK derivation
Jouni Malinen [Fri, 3 Feb 2017 12:37:30 +0000 (14:37 +0200)] 
ERP: Fix rIK derivation

Unlike the EMSKname and rRK derivations, rIK derivation is actually
using the "optional data" component in the context data (see RFC 5295).
RFC 6696 defines that optional data to be the cryptosuite field for rIK.
This was missing from the previous implementation and that resulted in
incorrect rIK being derived.

In addition, the rIK Label string does not actually include the "EAP "
prefix in the way as the rRK Label in RFC 6696 does. This would also
have resulted in incorrect rIK value.

Fix rIK derivation by adding the cryptosuite value into the KDF context
data and fixing the label string. This change is not backwards
compatible and breaks all ERP use cases (including FILS shared key
authentication) with older (broken) and new (fixed)
hostapd/wpa_supplicant builds.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agotests: FILS HLP request with DHCPDISCOVER
Jouni Malinen [Tue, 31 Jan 2017 12:41:24 +0000 (14:41 +0200)] 
tests: FILS HLP request with DHCPDISCOVER

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoFILS: Parse and report received FILS HLP Containers from response
Jouni Malinen [Tue, 31 Jan 2017 19:21:24 +0000 (21:21 +0200)] 
FILS: Parse and report received FILS HLP Containers from response

The new FILS-HLP-RX control interface event is now used to report
received FILS HLP responses from (Re)Association Response frame as a
response to the HLP requests configured with FILS_HLP_REQ_ADD.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoFILS: DHCP relay for HLP requests
Jouni Malinen [Tue, 31 Jan 2017 12:38:44 +0000 (14:38 +0200)] 
FILS: DHCP relay for HLP requests

The new dhcp_server configuration parameter can now be used to configure
hostapd to act as a DHCP relay for DHCPDISCOVER messages received as
FILS HLP requests. The dhcp_rapid_commit_proxy=1 parameter can be used
to configure hostapd to convert 4 message DHCP exchange into a 2 message
exchange in case the DHCP server does not support DHCP rapid commit
option.

The fils_hlp_wait_time parameter can be used to set the time hostapd
waits for an HLP response. This matches the dot11HLPWaitTime in IEEE Std
802.11ai-2016.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoFILS: Move HLP request handling into a separate file
Jouni Malinen [Tue, 31 Jan 2017 12:00:12 +0000 (14:00 +0200)] 
FILS: Move HLP request handling into a separate file

This is independent functionality from the core IEEE 802.11 management
handling and will increase significantly in size, so it is cleaner to
maintain this in a separate source code file.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoProxyARP: Use more robust DHCP option parsing
Jouni Malinen [Tue, 31 Jan 2017 12:43:56 +0000 (14:43 +0200)] 
ProxyARP: Use more robust DHCP option parsing

Do not depend on undefined behavior with pointer arithmetic when
checking whether there is sufficient room for an option.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoMove DHCP definitions into a common file
Jouni Malinen [Tue, 31 Jan 2017 11:52:58 +0000 (13:52 +0200)] 
Move DHCP definitions into a common file

These can be reused for other purposes than just the DHCP snoofing for
Proxy ARP. In addition, use more complete definition of the parameters
based on the current IANA registry.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoAdd QCA vendor definitions for BSS transition status
Kanchanapally, Vidyullatha [Tue, 24 Jan 2017 07:35:23 +0000 (13:05 +0530)] 
Add QCA vendor definitions for BSS transition status

Introduce definitions for QCA vendor specific subcommands and attributes
for fetching BSS transition status.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoAP: Check ACL upon association request for 802.11ad
Dedy Lansky [Tue, 17 Jan 2017 12:51:02 +0000 (14:51 +0200)] 
AP: Check ACL upon association request for 802.11ad

With device_ap_sme disabled, ACL was checked upon authentication
request. In 802.11ad there is no authentication phase so need to check
ACL upon association.

Signed-off-by: Dedy Lansky <qca_dlansky@qca.qualcomm.com>
7 years agotests: GAS long comeback delay over default STA timeout
Jouni Malinen [Mon, 30 Jan 2017 11:21:27 +0000 (13:21 +0200)] 
tests: GAS long comeback delay over default STA timeout

This verifies that the temporary STA entry timeout limit does not end up
breaking comeback_delay tests with values larger than five seconds.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoGAS: Set temporary session timeout bigger than gas_comeback_delay
Daniel Kim [Mon, 30 Jan 2017 11:23:29 +0000 (13:23 +0200)] 
GAS: Set temporary session timeout bigger than gas_comeback_delay

Previously, the temporary STA session timeout was set to 5 seconds. If
gas_comeback_delay is configured to be longer than 5 seconds, GAS
Comeback Response frame can't include queried information as all pending
data has already been cleared due to session timeout. This commit
resolves the issue by setting session timeout to be larger than
gas_comeback_delay.

Signed-off-by: Daniel Kim <kimdan@qca.qualcomm.com>
7 years agotests: Skip hapd_ctrl_test_fail if TEST_* commands not included in build
Jouni Malinen [Mon, 30 Jan 2017 10:01:04 +0000 (12:01 +0200)] 
tests: Skip hapd_ctrl_test_fail if TEST_* commands not included in build

This test case was triggering false failures with hostapd build that did
not include TEST_* commands.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoQCA vendor command to set/get NUD statistics
Sunil Dutt [Wed, 18 Jan 2017 14:47:01 +0000 (20:17 +0530)] 
QCA vendor command to set/get NUD statistics

This commit introduces QCA vendor commands and the corresponding
attributes to set/get NUD (Network Unreachability Detection) statistics.
The set NUD statistics configures the requisite parameters to the host
driver and thereby triggers the start/stop of collection of statistics.
The get stats fetches the statistics collected in the host driver.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agonl80211: Do not reset vendor_scan_cookie after scan timeout
Sunil Dutt [Wed, 25 Jan 2017 11:06:19 +0000 (16:36 +0530)] 
nl80211: Do not reset vendor_scan_cookie after scan timeout

If vendor_scan_cookie is set to 0 after the scan_abort due to the scan
timeout ends in a cookie mismatch when processing the following
QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE indication. This ends up considering
the scan results as being for an external scan and thus the current
ongoing scan is not removed from the radio_work. Hence, do not reset
this vendor_scan_cookie after the scan abort so that the scan completion
event gets processed properly and vendor_scan_cookie gets cleared at
that point.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
7 years agoOpenSSL/BoringSSL: Read certificate chain from client_cert on Android
Paul Stewart [Wed, 25 Jan 2017 21:59:16 +0000 (13:59 -0800)] 
OpenSSL/BoringSSL: Read certificate chain from client_cert on Android

If the keychain holds additional certificates other than the end
certificate, read them into the certificate chain.

Signed-off-by: Paul Stewart <pstew@google.com>
7 years agotests: wpa_supplicant AP mode - STA commands on global control interface
Jouni Malinen [Sun, 29 Jan 2017 23:13:13 +0000 (01:13 +0200)] 
tests: wpa_supplicant AP mode - STA commands on global control interface

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agowpa_supplicant: Fix global control interface for STA/STA-FIRST/STA-NEXT
Dmitry Shmidt [Tue, 24 Jan 2017 23:12:54 +0000 (23:12 +0000)] 
wpa_supplicant: Fix global control interface for STA/STA-FIRST/STA-NEXT

update_stations(ctrl_conn) is stuck in never-ending loop:

sendto(3, "STA-FIRST", 9, 0, NULL, 0)   = 9
pselect6(4, [3], NULL, NULL, {10, 0}, NULL) = 1 (in [3], left {9, 999995000})
recvfrom(3, "UNKNOWN COMMAND\n", 4095, 0, NULL, NULL) = 16
sendto(3, "STA-NEXT UNKNOWN COMMAND", 24, 0, NULL, 0) = 24
pselect6(4, [3], NULL, NULL, {10, 0}, NULL) = 1 (in [3], left {9, 999995833})
recvfrom(3, "UNKNOWN COMMAND\n", 4095, 0, NULL, NULL) = 16
sendto(3, "STA-NEXT UNKNOWN COMMAND", 24, 0, NULL, 0) = 24
pselect6(4, [3], NULL, NULL, {10, 0}, NULL) = 1 (in [3], left {9, 999995000})
recvfrom(3, "UNKNOWN COMMAND\n", 4095, 0, NULL, NULL) = 16
sendto(3, "STA-NEXT UNKNOWN COMMAND", 24, 0, NULL, 0) = 24

Direct STA, STA-FIRST, and STA-NEXT commands from the global control
interface to a per-interface control interface to avoid this.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
7 years agohostapd: Add possibility to send debug messages to syslog
Wojciech Dubowik [Mon, 23 Jan 2017 12:55:04 +0000 (13:55 +0100)] 
hostapd: Add possibility to send debug messages to syslog

We can only send module specific messages to syslog and not debug
messages printed with wpa_printf. Add an extra command line parameter
'-s' to allow it. The feature is enabled with compile flag
CONFIG_DEBUG_SYSLOG as for wpa_supplicant and behaves in the same manner
as the wpa_supplicant -s command line argument.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
7 years agoFST: Remove WPA_ASSERT from wpas_fst_send_action_cb()
Jouni Malinen [Sun, 29 Jan 2017 17:22:14 +0000 (19:22 +0200)] 
FST: Remove WPA_ASSERT from wpas_fst_send_action_cb()

It was possible to hit this WPA_ASSERT when FST-MANAGER SESSION_REMOVE
command is exececuted when in not-associated state. In
CONFIG_EAPOL_TEST=y builds, this would result in the wpa_supplicant
process being terminated. Convert this WPA_ASSERT to a check that does
not terminate the process, but only rejects the command if wpa_s->bssid
does not match the da argument.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoFST: Silence compiler warning on WPA_ASSERT
Jouni Malinen [Sun, 29 Jan 2017 16:45:29 +0000 (18:45 +0200)] 
FST: Silence compiler warning on WPA_ASSERT

This was triggering a sign-compare warning.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoFST: Remove a bogus WPA_ASSERT()
Jouni Malinen [Sun, 29 Jan 2017 16:44:36 +0000 (18:44 +0200)] 
FST: Remove a bogus WPA_ASSERT()

own_addr is not defined here, so no idea what this WPA_ASSERT() was
trying to check.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoIncrease delayed EAPOL RX frame timeout
Andrejs Cainikovs [Mon, 23 Jan 2017 12:34:46 +0000 (21:34 +0900)] 
Increase delayed EAPOL RX frame timeout

Increase the EAPOL RX frame timeout from 100 to 200 ms. This fixes lack
of optimization (i.e., first EAPOL frame dropped) in occasional roaming
and authentication cases on EAP networks if the kernel events can be
reordered and delayed a bit longer.

Signed-off-by: Tomoharu Hatano <tomoharu.hatano@sonymobile.com>
7 years agowpa_auth: Make struct wpa_auth_callbacks const
Johannes Berg [Thu, 26 Jan 2017 15:24:06 +0000 (16:24 +0100)] 
wpa_auth: Make struct wpa_auth_callbacks const

Instead of copying the struct wpa_auth_callbacks, just keep a pointer to
it, keep the context pointer separate, and let the user just provide a
static const structure. This reduces the attack surface of heap
overwrites, since the function pointers move elsewhere.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
7 years agoFix or supress various sparse warnings
Johannes Berg [Thu, 26 Jan 2017 12:09:25 +0000 (13:09 +0100)] 
Fix or supress various sparse warnings

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
7 years agotests: Mesh and HT40 support difference
Jouni Malinen [Sun, 29 Jan 2017 15:50:50 +0000 (17:50 +0200)] 
tests: Mesh and HT40 support difference

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agoIBSS/mesh: Skip VHT channel setup with vht_disabled=1
Jouni Malinen [Sun, 29 Jan 2017 16:10:24 +0000 (18:10 +0200)] 
IBSS/mesh: Skip VHT channel setup with vht_disabled=1

If the VHT capability override vht_disabled=1 is used in the network
profile, skip VHT configuration of the local channel.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agomesh: Check remote peer HT Operation element
Masashi Honma [Fri, 27 Jan 2017 04:43:19 +0000 (13:43 +0900)] 
mesh: Check remote peer HT Operation element

The remote mesh STA which had configuration disable_ht40=1 could have HT
Capabilities element which includes Supported Channel Width Set = 1
(both 20 MHz and 40 MHz operation is supported) even though it had HT
Operation element which includes STA Channel Width = 0 (20 MHz channel
width only). Previously, local peer recognized such a remote peer as 40
MHz band width enabled STA because local peer only checked HT
Capabilities element. This could cause disconnection between
disable_ht40=1 mesh STA and disable_ht40=0 mesh STA. They could
establish a mesh BSS but could not ping with ath9k_htc device. This
commit fixes the issue by refering HT Operation element.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
7 years agoDefine helper function set_disable_ht40()
Masashi Honma [Fri, 27 Jan 2017 04:43:19 +0000 (13:43 +0900)] 
Define helper function set_disable_ht40()

This functionality can be used outside wpa_set_disable_ht40(), so move
the generic part to a helper function.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
7 years agonl80211: Fix a memory leak on deinit with HT enabled mesh
Masashi Honma [Wed, 25 Jan 2017 00:22:32 +0000 (09:22 +0900)] 
nl80211: Fix a memory leak on deinit with HT enabled mesh

Commit a70cd0db876b2ffad7e3d608e3f9a2fcf2e7a879 ('nl80211: Don't
register for Beacon frames for IEEE 802.11ad AP') could cause a trailing
memory leak on IEEE 802.11n enabled mesh. This commit fixes the issue.

-----------------
ELOOP: remaining socket: sock=12 eloop_data=0xba8260 user_data=0xbb3d90 handler=0x4aeb90
WPA_TRACE: eloop unregistered socket handler: 0x4aeb90
     nl80211_recv_beacons() ../src/drivers/driver_nl80211.c:625
WPA_TRACE: eloop sock - START
[0]: ./hostap/wpa_supplicant/wpa_supplicant() [0x431f2a]
     eloop_sock_table_add_sock() ../src/utils/eloop.c:360
[1]: ./hostap/wpa_supplicant/wpa_supplicant() [0x4b0e49]
     nl80211_register_eloop_read() ../src/drivers/driver_nl80211.c:153
[2]: ./hostap/wpa_supplicant/wpa_supplicant() [0x4bacf0]
     dl_list_add() src/utils/list.h:30
     nl80211_get_wiphy_data_ap() ../src/drivers/driver_nl80211.c:728
     wpa_driver_nl80211_set_ap() ../src/drivers/driver_nl80211.c:3786
[3]: ./hostap/wpa_supplicant/wpa_supplicant(ieee802_11_set_beacon+0x150) [0x469700]
     ieee802_11_set_beacon() ../src/ap/beacon.c:1349
[4]: ./hostap/wpa_supplicant/wpa_supplicant(ieee802_11_set_beacons+0x45) [0x469805]
     ieee802_11_set_beacons() ../src/ap/beacon.c:1368
[5]: ./hostap/wpa_supplicant/wpa_supplicant() [0x437559]
     mesh_mpm_add_peer() mesh_mpm.c:688
[6]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_mesh_new_mesh_peer+0x42) [0x439182]
     wpa_mesh_new_mesh_peer() mesh_mpm.c:737
[7]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_mesh_notify_peer+0x80) [0x436460]
     wpa_mesh_notify_peer() mesh.c:347
[8]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_supplicant_event+0xc7a) [0x4a69ba]
     wpa_supplicant_event() events.c:4312
[9]: ./hostap/wpa_supplicant/wpa_supplicant(process_global_event+0xaf0) [0x4c2d40]
     nl80211_new_peer_candidate() ../src/drivers/driver_nl80211_event.c:1247
     do_process_drv_event() ../src/drivers/driver_nl80211_event.c:2322
     process_global_event() ../src/drivers/driver_nl80211_event.c:2360
[10]: /lib/x86_64-linux-gnu/libnl-3.so.200(nl_recvmsgs_report+0x3dc) [0x7f937176873c]
[11]: /lib/x86_64-linux-gnu/libnl-3.so.200(nl_recvmsgs+0x9) [0x7f9371768ba9]
[12]: ./hostap/wpa_supplicant/wpa_supplicant() [0x4aeb58]
     wpa_driver_nl80211_event_receive() ../src/drivers/driver_nl80211.c:1457
[13]: ./hostap/wpa_supplicant/wpa_supplicant() [0x43242e]
     eloop_sock_table_dispatch() ../src/utils/eloop.c:598
[14]: ./hostap/wpa_supplicant/wpa_supplicant(eloop_run+0x22e) [0x432e0e]
     eloop_sock_table_dispatch() ../src/utils/eloop.c:589
     eloop_run() ../src/utils/eloop.c:1219
[15]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_supplicant_run+0x77) [0x49e327]
     wpa_supplicant_run() wpa_supplicant.c:5608
WPA_TRACE: eloop sock - END
MEMLEAK[0xba81b0]: len 72
WPA_TRACE: memleak - START
[0]: ./hostap/wpa_supplicant/wpa_supplicant(os_malloc+0x57) [0x430d67]
     os_malloc() ../src/utils/os_unix.c:690
[1]: ./hostap/wpa_supplicant/wpa_supplicant(os_zalloc+0xe) [0x430fce]
     os_zalloc() ../src/utils/os_unix.c:749
[2]: ./hostap/wpa_supplicant/wpa_supplicant() [0x4babaa]
     nl80211_get_wiphy_data_ap() ../src/drivers/driver_nl80211.c:692
     wpa_driver_nl80211_set_ap() ../src/drivers/driver_nl80211.c:3786
[3]: ./hostap/wpa_supplicant/wpa_supplicant(ieee802_11_set_beacon+0x150) [0x469700]
     ieee802_11_set_beacon() ../src/ap/beacon.c:1349
[4]: ./hostap/wpa_supplicant/wpa_supplicant(ieee802_11_set_beacons+0x45) [0x469805]
     ieee802_11_set_beacons() ../src/ap/beacon.c:1368
[5]: ./hostap/wpa_supplicant/wpa_supplicant() [0x437559]
     mesh_mpm_add_peer() mesh_mpm.c:688
[6]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_mesh_new_mesh_peer+0x42) [0x439182]
     wpa_mesh_new_mesh_peer() mesh_mpm.c:737
[7]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_mesh_notify_peer+0x80) [0x436460]
     wpa_mesh_notify_peer() mesh.c:347
[8]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_supplicant_event+0xc7a) [0x4a69ba]
     wpa_supplicant_event() events.c:4312
[9]: ./hostap/wpa_supplicant/wpa_supplicant(process_global_event+0xaf0) [0x4c2d40]
     nl80211_new_peer_candidate() ../src/drivers/driver_nl80211_event.c:1247
     do_process_drv_event() ../src/drivers/driver_nl80211_event.c:2322
     process_global_event() ../src/drivers/driver_nl80211_event.c:2360
[10]: /lib/x86_64-linux-gnu/libnl-3.so.200(nl_recvmsgs_report+0x3dc) [0x7f937176873c]
[11]: /lib/x86_64-linux-gnu/libnl-3.so.200(nl_recvmsgs+0x9) [0x7f9371768ba9]
[12]: ./hostap/wpa_supplicant/wpa_supplicant() [0x4aeb58]
     wpa_driver_nl80211_event_receive() ../src/drivers/driver_nl80211.c:1457
[13]: ./hostap/wpa_supplicant/wpa_supplicant() [0x43242e]
     eloop_sock_table_dispatch() ../src/utils/eloop.c:598
[14]: ./hostap/wpa_supplicant/wpa_supplicant(eloop_run+0x22e) [0x432e0e]
     eloop_sock_table_dispatch() ../src/utils/eloop.c:589
     eloop_run() ../src/utils/eloop.c:1219
[15]: ./hostap/wpa_supplicant/wpa_supplicant(wpa_supplicant_run+0x77) [0x49e327]
     wpa_supplicant_run() wpa_supplicant.c:5608
WPA_TRACE: memleak - END
MEMLEAK: total 72 bytes
-----------------

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
7 years agotests: wpa_supplicant mesh with dynamic interface and removal
Jouni Malinen [Sun, 29 Jan 2017 15:38:37 +0000 (17:38 +0200)] 
tests: wpa_supplicant mesh with dynamic interface and removal

This is a regression test case for SIGSEGV in
wpa_supplicant_remove_iface() if the main interface is removed while a
separate mesh interface is in use.

Signed-off-by: Jouni Malinen <j@w1.fi>
7 years agomesh: Fix crash on removing virtual mesh interface
Saurav Babu [Fri, 27 Jan 2017 11:46:51 +0000 (17:16 +0530)] 
mesh: Fix crash on removing virtual mesh interface

If a virtual mesh interface has been created and is still operational
when the main interface is removed (e.g., Wi-Fi hardware ejected), the
following crash occurred with the below backtrace:

WPA_TRACE: eloop SIGSEGV - START
[1]: /usr/local/sbin/wpa_supplicant() [0x44ef7e]
     eloop_sigsegv_handler() home/saurav/hostap/wpa_supplicant/../src/utils/eloop.c:123
[2]: /lib/x86_64-linux-gnu/libc.so.6(+0x36d40) [0x7f4c395cfd40]
[3]: /usr/local/sbin/wpa_supplicant(wpa_supplicant_remove_iface+0xd0) [0x57f500]
     wpa_supplicant_remove_iface() home/saurav/hostap/wpa_supplicant/wpa_supplicant.c:5338
[4]: /usr/local/sbin/wpa_supplicant() [0x57fbef]
     wpa_supplicant_deinit_iface() home/saurav/hostap/wpa_supplicant/wpa_supplicant.c:5069
[5]: /usr/local/sbin/wpa_supplicant(wpa_supplicant_remove_iface+0xc5) [0x57f4f5]
     wpa_supplicant_remove_iface() home/saurav/hostap/wpa_supplicant/wpa_supplicant.c:5343
[6]: /usr/local/sbin/wpa_supplicant(wpas_dbus_handler_remove_interface+0x8d) [0x55baad]
     wpas_dbus_handler_remove_interface() home/saurav/hostap/wpa_supplicant/dbus/dbus_new_handlers.c:679
[7]: /usr/local/sbin/wpa_supplicant() [0x5560cb]
     msg_method_handler() home/saurav/hostap/wpa_supplicant/dbus/dbus_new_helpers.c:354
     message_handler() home/saurav/hostap/wpa_supplicant/dbus/dbus_new_helpers.c:410
[8]: /lib/x86_64-linux-gnu/libdbus-1.so.3(+0x1be86) [0x7f4c39979e86]
[9]: /lib/x86_64-linux-gnu/libdbus-1.so.3(dbus_connection_dispatch+0x381) [0x7f4c3996ca21]
[10]: /usr/local/sbin/wpa_supplicant() [0x567148]
     dispatch_data() home/saurav/hostap/wpa_supplicant/dbus/dbus_common.c:36
[11]: /usr/local/sbin/wpa_supplicant() [0x5674a7]
     process_watch() home/saurav/hostap/wpa_supplicant/dbus/dbus_common.c:75
     process_watch_read() home/saurav/hostap/wpa_supplicant/dbus/dbus_common.c:90
[12]: /usr/local/sbin/wpa_supplicant() [0x44f297]
     eloop_sock_table_dispatch() home/saurav/hostap/wpa_supplicant/../src/utils/eloop.c:598
[13]: /usr/local/sbin/wpa_supplicant(eloop_run+0x1fe) [0x44ff1e]
     eloop_run() home/saurav/hostap/wpa_supplicant/../src/utils/eloop.c:1219
[14]: /usr/local/sbin/wpa_supplicant(wpa_supplicant_run+0x77) [0x57fd87]
     wpa_supplicant_run() home/saurav/hostap/wpa_supplicant/wpa_supplicant.c:5608
[15]: /usr/local/sbin/wpa_supplicant(main+0x3a8) [0x43ba88]
     main() home/saurav/hostap/wpa_supplicant/main.c:392
WPA_TRACE: eloop SIGSEGV - END
Aborted (core dumped)

Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
7 years agotests: Remove mesh before trying to clear BSS cache
Jouni Malinen [Sun, 29 Jan 2017 14:27:07 +0000 (16:27 +0200)] 
tests: Remove mesh before trying to clear BSS cache

The flush_scan_cache() operations in the finally part of these test
cases ended up getting called when the mesh group was still operating.
This could result in unexpected behavior due to offchannel scan being
performed before the device becomes idle. Clean this up by explicitly
removing the mesh group before cleaning up.

Signed-off-by: Jouni Malinen <j@w1.fi>