mech_eap.git
9 years agomesh: Retransmit the last Commit Message in the Committed state
Masashi Honma [Wed, 15 Apr 2015 10:28:16 +0000 (19:28 +0900)]
mesh: Retransmit the last Commit Message in the Committed state

Previously, mesh state machine transmits updated Commit Message when
receiving a Confirm Message in Committed state. According to the
standard, it should (re)send the latest Commit Message previously sent.

IEEE Std 802.11-2012, 11.3.8.6.4 Protocol instance behavior - Committed
state:
"Upon receipt of a Con event, ... If Sync is not greater than
dot11RSNASAESync, the protocol instance shall increment Sync, transmit
the last Commit Message sent to the peer, and set the t0
(retransmission) timer."

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
9 years agotests: Verify dynamic_vlan=required is honored with macaddr_acl=2
Michael Braun [Tue, 14 Apr 2015 14:56:37 +0000 (16:56 +0200)]
tests: Verify dynamic_vlan=required is honored with macaddr_acl=2

dynamic_vlan=required also applies to macaddr_acl=2 (RADIUS), especially
when used with WPA-PSK.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agovlan: Verify RADIUS returned VLAN-ID and dynamic_vlan=required
Michael Braun [Tue, 14 Apr 2015 14:56:38 +0000 (16:56 +0200)]
vlan: Verify RADIUS returned VLAN-ID and dynamic_vlan=required

This extends dynamic_vlan=required checks to apply for WPA-PSK with
macaddr_acl=2 (RADIUS) case.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agotests: WPS AP iteration on no Selected Registrar and error case
Jouni Malinen [Fri, 24 Apr 2015 13:47:51 +0000 (16:47 +0300)]
tests: WPS AP iteration on no Selected Registrar and error case

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoWPS: Use shorter authentication timeout during no-SelReg iteration
Jouni Malinen [Fri, 24 Apr 2015 13:45:27 +0000 (16:45 +0300)]
WPS: Use shorter authentication timeout during no-SelReg iteration

When iterating through WPS APs that do not advertise Selected Registrar
TRUE, limit the authentication timeout to 10 seconds instead of the full
70 second value used with IEEE 802.1X/EAP/WPS in general. This helps
speed up AP iteration for cases where a selected AP misbehaves and does
not reply to EAP exchanges. This should not really be needed, but there
seems to be deployed APs that do not implement WPS correctly and with
such APs in the radio range, this extra timeout can speed up the
iteration to allow the correct AP to be found before the WPS operation
times out.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoWPS: Enforce five second minimum time before AP iteration
Hu Wang [Fri, 24 Apr 2015 12:53:08 +0000 (15:53 +0300)]
WPS: Enforce five second minimum time before AP iteration

Previously, wpa_supplicant was using number of scan iterations
(WPS_PIN_SCAN_IGNORE_SEL_REG = 3) to give some time for finding a WPS AP
with Selected Registrar TRUE before starting to iterate through all WPS
APs. While this works fine in most cases, some drivers may return the
initial three scan results so quickly that the total amount of time is
only couple of seconds in case none of the APs are initially advertising
Selected Registrar TRUE. To give some more time for APs (WPS Registrars)
to become ready, add an additional constraint on the iteration based on
time (WPS_PIN_TIME_IGNORE_SEL_REG = 5 seconds).

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agotests: Increase wait timeout in autogo_m2d
Jouni Malinen [Fri, 24 Apr 2015 14:54:13 +0000 (17:54 +0300)]
tests: Increase wait timeout in autogo_m2d

The time before trying to associate with an AP that does not advertise
Selected Registrar TRUE is going to be incremented, so increase the
autogo_m2d timeout to avoid reporting incorrect errors due to missing
M2D events.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoRemove trailing whitespace from Makefile
Jouni Malinen [Thu, 23 Apr 2015 21:57:38 +0000 (00:57 +0300)]
Remove trailing whitespace from Makefile

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoP2P: Do not create a P2P Device interface if P2P is disabled
Ilan Peer [Wed, 22 Apr 2015 10:13:18 +0000 (13:13 +0300)]
P2P: Do not create a P2P Device interface if P2P is disabled

Do not add the dedicated P2P Device interface in case P2P is disabled in
the configuration file or globally.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
9 years agoDocument p2p_disabled option in wpa_supplicant.conf
Ben Greear [Mon, 20 Apr 2015 23:54:27 +0000 (19:54 -0400)]
Document p2p_disabled option in wpa_supplicant.conf

I needed this option to disable P2P on a buggy system.
Document this so someone else finds it quicker next time.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agotests: D-Bus AddNetwork for AP mode
Jouni Malinen [Thu, 23 Apr 2015 21:46:24 +0000 (00:46 +0300)]
tests: D-Bus AddNetwork for AP mode

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agotests: wpa_supplicant INTERFACE_ADD/REMOVE with large number of vifs
Jouni Malinen [Thu, 23 Apr 2015 21:08:41 +0000 (00:08 +0300)]
tests: wpa_supplicant INTERFACE_ADD/REMOVE with large number of vifs

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agonl80211: Extend unique MAC address assignment for station iftype
Jouni Malinen [Thu, 23 Apr 2015 16:11:36 +0000 (19:11 +0300)]
nl80211: Extend unique MAC address assignment for station iftype

Previously, only P2P and mesh use cases enforced unique MAC address for
a dynamically added virtual interface. Extend this to cover normal
station mode interfaces since those can now be added with INTERFACE_ADD.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoWPS: Explicitly reject Public Key attribute with unexpected length
Jouni Malinen [Sun, 19 Apr 2015 14:45:33 +0000 (17:45 +0300)]
WPS: Explicitly reject Public Key attribute with unexpected length

There is no need to try to derive DH shared key with a peer that tries
to use too short or too long DH Public Key. Previously, such cases ended
up implicitly getting rejected by the DH operations failing to produce
matching results. That is unnecessarily, so simply reject the message
completely if it does not have a Public Key with valid length. Accept
couple of octets shorter value to be used to avoid interoperability
issues if there are implementations that do not use zero-padding
properly.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoWPS: Truncate variable length string attributes to maximum length
Jouni Malinen [Sun, 19 Apr 2015 14:17:37 +0000 (17:17 +0300)]
WPS: Truncate variable length string attributes to maximum length

This enforces variable length strings Manufacturer, Model Name, Model
Number, and Serial Number to be within the maximum length defined in the
WSC specification. While none of the existing users for these within
hostapd/wpa_supplicant had problems with longer strings, it is good to
ensure the strings are not longer to avoid potential issues at higher
layer components.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoSimplify VHT Operation element parsing
Jouni Malinen [Sun, 19 Apr 2015 14:03:23 +0000 (17:03 +0300)]
Simplify VHT Operation element parsing

Check the element length in the parser and remove the length field from
struct ieee802_11_elems since the element is of fixed length.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoSimplify HT Operation element parsing
Jouni Malinen [Sun, 19 Apr 2015 14:01:25 +0000 (17:01 +0300)]
Simplify HT Operation element parsing

Check the element length in the parser and remove the length field from
struct ieee802_11_elems since the element is of fixed length.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoSimplify VHT Capabilities element parsing
Jouni Malinen [Sun, 19 Apr 2015 14:00:45 +0000 (17:00 +0300)]
Simplify VHT Capabilities element parsing

Check the element length in the parser and remove the length field from
struct ieee802_11_elems since the element is of fixed length.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoSimplify HT Capabilities element parsing
Jouni Malinen [Sun, 19 Apr 2015 13:48:21 +0000 (16:48 +0300)]
Simplify HT Capabilities element parsing

Check the element length in the parser and remove the length field from
struct ieee802_11_elems since the element is of fixed length.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoSimplify Timeout Interval element parsing
Jouni Malinen [Sun, 19 Apr 2015 13:38:11 +0000 (16:38 +0300)]
Simplify Timeout Interval element parsing

Remove the length field from struct ieee802_11_elems since the only
allowed element length is five and that is checked by the parser.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoSimplify ERP element parsing
Jouni Malinen [Sun, 19 Apr 2015 13:35:52 +0000 (16:35 +0300)]
Simplify ERP element parsing

Check the element length in the parser and remove the length field from
struct ieee802_11_elems since the only allowed element length is one.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoSimplify DSSS Parameter Set element parsing
Jouni Malinen [Sun, 19 Apr 2015 13:32:01 +0000 (16:32 +0300)]
Simplify DSSS Parameter Set element parsing

Check the element length in the parser and remove the length field from
struct ieee802_11_elems since the only allowed element length is one.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoFT: Check FT, MD, and Timeout Interval length in the parser
Jouni Malinen [Sun, 19 Apr 2015 13:28:35 +0000 (16:28 +0300)]
FT: Check FT, MD, and Timeout Interval length in the parser

All the existing users of these elements were already validating the
element length. However, it is clearer to validate this already at the
parser for extra layer of protection for any future changes.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoFix a memory leak on mesh_attr_text() error path
Jouni Malinen [Sun, 19 Apr 2015 08:57:05 +0000 (11:57 +0300)]
Fix a memory leak on mesh_attr_text() error path

Should there not be enough room in the output buffer, the
bss_basic_rate_set line would not be printed. This error case was
handled otherwise, but the temporary memory allocation for building the
information was not freed.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agowlantest: Verify FTIE length before checking MIC
Jouni Malinen [Sun, 19 Apr 2015 08:42:02 +0000 (11:42 +0300)]
wlantest: Verify FTIE length before checking MIC

tdls_verify_mic() and tdls_verify_mic_teardown() could have tried to
read the 16-octet FTIE MIC when processing a TDLS frame even if the
received FTIE is truncated. At least in theory, this could result in
reading couple of octets beyond the frame buffer.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoFT: Fix WMM TSPEC validation in driver-based AP MLME case
Jouni Malinen [Sun, 19 Apr 2015 08:15:58 +0000 (11:15 +0300)]
FT: Fix WMM TSPEC validation in driver-based AP MLME case

Commit 88b32a99d30894b2d6bb391371c442fc117edbab ('FT: Add FT AP support
for drivers that manage MLME internally') added an alternative way of
processing the WMM TSPEC from RIC. However, that change did not seem to
include the same checks for WMM TSPEC element length that were used in
the original implementation for MLME-in-hostapd case. Fix this by
sharing the older implementation of copying the WMM TSPEC from RIC for
both cases.

It looks like the destination buffer for the response is sufficiently
long for the fixed length copy, but it may have been possible to trigger
a read beyond the end of the FTIE by about 50 bytes. Though, that seems
to be within the buffer received for RX buffer in the case that uses
this driver-based AP MLME design for FT.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agowlantest: Fix Beacon and Probe Response frame parser
Jouni Malinen [Sat, 18 Apr 2015 14:59:30 +0000 (17:59 +0300)]
wlantest: Fix Beacon and Probe Response frame parser

These functions did not verify that the received frame is long enough to
contain the beginning of the variable length IE area. A truncated frame
could have caused a segmentation fault due to reading beyond the buffer.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agotests: Add ap-mgmt-fuzzer
Jouni Malinen [Sat, 18 Apr 2015 13:27:18 +0000 (16:27 +0300)]
tests: Add ap-mgmt-fuzzer

This program can be used to run fuzzing tests for areas related to AP
management frame parsing and processing.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agotests: Add wnm-fuzzer
Jouni Malinen [Sat, 18 Apr 2015 10:42:24 +0000 (13:42 +0300)]
tests: Add wnm-fuzzer

This program can be used to run fuzzing tests for areas related to WNM
frame parsing and processing on the client side.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agotests: Add eapol-fuzzer
Jouni Malinen [Sat, 18 Apr 2015 08:31:11 +0000 (11:31 +0300)]
tests: Add eapol-fuzzer

This program can be used to run fuzzing tests for areas related to EAPOL
frame parsing and processing on the supplicant side.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agotests: Add p2p-fuzzer
Jouni Malinen [Wed, 8 Apr 2015 20:12:25 +0000 (23:12 +0300)]
tests: Add p2p-fuzzer

This program can be used to run fuzzing tests for areas related to P2P
message parsing and processing. p2p-fuzzer allows data files to be used
to inject Probe Response and Action frames for processing by the P2P
module.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoP2P: Use WPS_SEC_DEV_TYPE_MAX_LEN in P2P array definition
Jouni Malinen [Tue, 7 Apr 2015 13:06:43 +0000 (16:06 +0300)]
P2P: Use WPS_SEC_DEV_TYPE_MAX_LEN in P2P array definition

This makes it more obvious that the wps_parse_msg() bounds checking is
used to verify that there is sufficient space in the P2P buffer for the
secondary device types.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agotests: Add a module test for wpa_ssid_txt() with too long SSID
Jouni Malinen [Tue, 7 Apr 2015 12:52:34 +0000 (15:52 +0300)]
tests: Add a module test for wpa_ssid_txt() with too long SSID

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com
9 years agoUse common is_ctrl_char() helper function
Jouni Malinen [Tue, 7 Apr 2015 12:43:32 +0000 (15:43 +0300)]
Use common is_ctrl_char() helper function

This modifies couple of code segments that replaced control characters
in strings with '_' to use a common helper function.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agotests: P2P protocol tests for too long variable length fields
Jouni Malinen [Tue, 7 Apr 2015 12:31:37 +0000 (15:31 +0300)]
tests: P2P protocol tests for too long variable length fields

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoWPS: Ignore too long SSID attribute
Jouni Malinen [Tue, 7 Apr 2015 10:22:49 +0000 (13:22 +0300)]
WPS: Ignore too long SSID attribute

While it looks like all the users of this parsed attribute were able to
handle longer SSID values, there is no valid use case for these and to
avoid any potential future issues, enforce maximum length (32 bytes) on
the SSID during parsing.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoReplace SSID_LEN with SSID_MAX_LEN
Jouni Malinen [Tue, 7 Apr 2015 09:59:29 +0000 (12:59 +0300)]
Replace SSID_LEN with SSID_MAX_LEN

This makes source code more consistent.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoReplace MAX_SSID_LEN with SSID_MAX_LEN
Jouni Malinen [Tue, 7 Apr 2015 09:44:39 +0000 (12:44 +0300)]
Replace MAX_SSID_LEN with SSID_MAX_LEN

This makes source code more consistent. The use within Android driver
interface is left as-is to avoid changes in the old PNO interface
definition.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoReplace HOSTAPD_MAX_SSID_LEN with SSID_MAX_LEN
Jouni Malinen [Tue, 7 Apr 2015 09:41:20 +0000 (12:41 +0300)]
Replace HOSTAPD_MAX_SSID_LEN with SSID_MAX_LEN

This makes source code more consistent.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoReplace WPA_MAX_SSID_LEN with SSID_MAX_LEN
Jouni Malinen [Tue, 7 Apr 2015 09:38:56 +0000 (12:38 +0300)]
Replace WPA_MAX_SSID_LEN with SSID_MAX_LEN

This makes the source code more consistent.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoUse SSID_MAX_LEN define instead of value 32 when comparing SSID length
Jouni Malinen [Tue, 7 Apr 2015 09:00:13 +0000 (12:00 +0300)]
Use SSID_MAX_LEN define instead of value 32 when comparing SSID length

This makes the implementation easier to understand.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoWPS: Ignore too long Device Name attribute
Jouni Malinen [Tue, 7 Apr 2015 09:10:50 +0000 (12:10 +0300)]
WPS: Ignore too long Device Name attribute

While it looks like all the users of this parsed attribute were able to
handle longer Device Name values, there is no valid use case for these
and to avoid any potential issues in upper layer components, enforce
maximum length (32 bytes) on the Device Name during parsing.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoAdd WPS_DEV_NAME_MAX_LEN define and use it when comparing length
Jouni Malinen [Tue, 7 Apr 2015 09:04:58 +0000 (12:04 +0300)]
Add WPS_DEV_NAME_MAX_LEN define and use it when comparing length

This make code easier to understand.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoP2PS: Check for maximum SSID length in Persistent Group Info
Jouni Malinen [Tue, 7 Apr 2015 08:52:42 +0000 (11:52 +0300)]
P2PS: Check for maximum SSID length in Persistent Group Info

While none of the current users of msg.persistent_ssid{,_len} would have
issues with too long SSID value, it is safer to enforce bounds checking
on the SSID while parsing the attribute to avoid any potential issues in
the future.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoIgnore too long SSID element value in parser
Jouni Malinen [Tue, 7 Apr 2015 08:50:10 +0000 (11:50 +0300)]
Ignore too long SSID element value in parser

The SSID element is defined to have a valid length range of 0-32. While
this length was supposed to validated by the users of the element
parser, there are not really any valid cases where the maximum length of
32 octet SSID would be exceeded and as such, the parser itself can
enforce the limit as an additional protection.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoP2P: Validate SSID element length before copying it (CVE-2015-1863)
Jouni Malinen [Tue, 7 Apr 2015 08:32:11 +0000 (11:32 +0300)]
P2P: Validate SSID element length before copying it (CVE-2015-1863)

This fixes a possible memcpy overflow for P2P dev->oper_ssid in
p2p_add_device(). The length provided by the peer device (0..255 bytes)
was used without proper bounds checking and that could have resulted in
arbitrary data of up to 223 bytes being written beyond the end of the
dev->oper_ssid[] array (of which about 150 bytes would be beyond the
heap allocation) when processing a corrupted management frame for P2P
peer discovery purposes.

This could result in corrupted state in heap, unexpected program
behavior due to corrupted P2P peer device information, denial of service
due to process crash, exposure of memory contents during GO Negotiation,
and potentially arbitrary code execution.

Thanks to Google security team for reporting this issue and smart
hardware research group of Alibaba security team for discovering it.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoMark QCA vendor command id 53 reserved, but not used anymore
Jouni Malinen [Wed, 22 Apr 2015 08:21:18 +0000 (11:21 +0300)]
Mark QCA vendor command id 53 reserved, but not used anymore

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoRemove unused leftover from multi-SSID design
Jouni Malinen [Mon, 20 Apr 2015 21:33:25 +0000 (00:33 +0300)]
Remove unused leftover from multi-SSID design

The multi-SSID design that used a single beaconing BSSID with multiple
SSIDs was never completed in this repository, so there is no need to
maintain the per-STA ssid/ssid_probe pointers that could only point to
&hapd->conf->ssid. Save some memory and reduce code complexity by
removing this unused partial capability.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoOpenSSL: Clean up TLS PRF implementation
Jouni Malinen [Sun, 19 Apr 2015 17:34:12 +0000 (20:34 +0300)]
OpenSSL: Clean up TLS PRF implementation

Commit fa0e715100b0e6fd956b6de67c3cdf908437436a ('Use
tls_connection_prf() for all EAP TLS-based key derivation') copied some
pointer checks from the generic implementation to tls_openssl.c.
However, these are arrays and cannot be NULL in OpenSSL data. Remove the
unnecessary checks and add master_key_length check for completeness.
(CID 109619).

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoAdd QCA vendor subcmd for OCB
Jouni Malinen [Tue, 21 Apr 2015 22:05:52 +0000 (01:05 +0300)]
Add QCA vendor subcmd for OCB

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoeap_example: Fix configuration by added DH parameters
Jouni Malinen [Fri, 17 Apr 2015 08:26:36 +0000 (11:26 +0300)]
eap_example: Fix configuration by added DH parameters

The internal TLS implementation supports number of additional cipher
suites that require DH parameters to be set on the server. Such a cipher
suite is selected by default in the eap_example case which prevented the
TLS handshake from completing successfully. Fix this by adding DH
parameters to the server configuration.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoAdd ifname to vlan_remove_dynamic() debug print
Jouni Malinen [Mon, 13 Apr 2015 14:06:12 +0000 (17:06 +0300)]
Add ifname to vlan_remove_dynamic() debug print

This makes it easier to interpret debug logs for cases where hostapd
control multiple interfaces.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoPrint debug entry on STA pruning from other interfaces
Jouni Malinen [Mon, 13 Apr 2015 14:01:21 +0000 (17:01 +0300)]
Print debug entry on STA pruning from other interfaces

This makes it easier to interpret debug logs in case hostapd controls
multiple interfaces and a STA roams between them.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agotests: Verify RSN preauth with dynamic VLANs
Michael Braun [Fri, 10 Apr 2015 12:49:45 +0000 (14:49 +0200)]
tests: Verify RSN preauth with dynamic VLANs

This change add two new tests to verify hostapd operation when used with
VLANs. Both are based on pmksa_cache_preauth and enable dynamic VLANs,
pmksa_cache_preauth_vlan_used additionally uses a station with VID 1.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agoRemove VLAN interface on STA free
Michael Braun [Fri, 10 Apr 2015 12:49:50 +0000 (14:49 +0200)]
Remove VLAN interface on STA free

Currently, vlan_remove_dynamic() is only called when the station VLAN ID
is changed (ap_sta_bind_vlan), but not when the station is freed. So
dynamic VLAN interfaces are not removed actually except within 1x
reauthentification VLAN ID change, although most of the code is already
there.

This patch fixes this by calling vlan_remove_dynamic() in ap_free_sta().

It cannot just use sta->vlan_id for this, as this might have been
changed without calling ap_sta_bind_vlan() (ap/ieee802_11.c:handle_auth
fetches from RADIUS cache for WPA-PSK), thus reference counting might
not have been updated. Additionally, reference counting might get wrong
due to old_vlanid = 0 being passed unconditionally, thus increasing the
reference counter multiple times.

So tracking the currently assigned (i.e., dynamic_vlan counter
increased) VLAN is done in a new variable sta->vlan_id_bound. Therefore,
the old_vlan_id argument of ap_sta_bind_vlan() is no longer needed and
setting the VLAN for the sta in driver happens unconditionally.

Additionally, vlan->dynamic_vlan is only incremented when it actually
is a dynamic VLAN.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agovlan: Ignore multiple NEWLINK messages
Michael Braun [Fri, 10 Apr 2015 12:49:49 +0000 (14:49 +0200)]
vlan: Ignore multiple NEWLINK messages

hostapd receives NEWLINK messages multiple times and thus does
configuration of the the vlan interface multiple times.

This is not required and leads to the following during cleanup in
test pmksa_cache_preauth_vlan_used:
 1. run-test.py does: brctl delif brvlan1 wlan3.1
 2. hostapd processes NEWLINK and does: brctl addif brvlan1 wlan3.1
 3. run-test.py does: brctl delbr brvlan1
    -> fails as wlan3.1 is still in the bridge

This patch fixes this by ignoring repeated NEWLINK messages.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agovlan: Ignore DELLINK on interfaces that exists
Michael Braun [Fri, 10 Apr 2015 12:49:48 +0000 (14:49 +0200)]
vlan: Ignore DELLINK on interfaces that exists

When hitting
> Failed to create interface wlan3.1: -23 (Too many open files in system)
> Try to remove and re-create wlan3.1
hostapd deletes the AP_VLAN interface and then recreates it. Thus the
kernel assigns the same ifidx to the new interfaces and sends DELLINK
and NEWLINK mesages.

As the DELLINK messages are processed after the struct hostapd_vlan is
added, hostapd deletes the struct hostapd_vlan entry, deconfigures the
AP_VLAN interface and leaves vlan_newlink nothing to find afterwards.

So this patch makes DELLINK messages to be ignored when the interface
exists.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agoFix STA VLAN bind for RSN pre-authentication case
Michael Braun [Fri, 10 Apr 2015 12:49:47 +0000 (14:49 +0200)]
Fix STA VLAN bind for RSN pre-authentication case

Previously, during RSN preauthentication, ap_sta_bind_vlan() was called,
which fails for non-zero sta->vlan_id as the station is not known to the
kernel driver.

Fix this by binding the station only if it is associated. If it is not
associated, ap_sta_bind_vlan() will be done later during association.

In addition, reject Access-Accept if the returned VLAN ID is not valid
in the current hostapd configuration.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agoFix RSN preauthentication with dynamic_vlan enabled but unused
Michael Braun [Fri, 10 Apr 2015 12:49:46 +0000 (14:49 +0200)]
Fix RSN preauthentication with dynamic_vlan enabled but unused

sta->vlan_id == -1 means no VLAN, as does vlan_id = 0.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 years agotests: D-Bus BSS interface and WPS Type values
Jouni Malinen [Mon, 13 Apr 2015 12:09:23 +0000 (15:09 +0300)]
tests: D-Bus BSS interface and WPS Type values

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agodbus: Fix WPS property of fi.w1.wpa_supplicant1.BSS interface
Floris Bos [Sat, 11 Apr 2015 00:11:46 +0000 (02:11 +0200)]
dbus: Fix WPS property of fi.w1.wpa_supplicant1.BSS interface

The dbus interface documentation says the following about the
WPS property of the fi.w1.wpa_supplicant1.BSS interface:

==
WPS information of the BSS. Empty dictionary indicates no WPS support.
Dictionary entries are:

Type s "pbc", "pin", ""
==

However the implementation returns "type" => "" for BSSes
that do not support WPS.

Fix the implementation to match the documentation.
Return empty dictionary if there is no WPS support.
And "type" => "" if WPS is supported, but is not in progress
right now.

Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>
9 years agoUpdates for stricter automatic memcpy bounds checking
Nick Kralevich [Sun, 12 Apr 2015 20:20:26 +0000 (13:20 -0700)]
Updates for stricter automatic memcpy bounds checking

Both Android's libc and glibc support _FORTIFY_SOURCE, a compiler
and libc feature which inserts automatic bounds checking into
common C functions such as memcpy() and strcpy(). If a buffer
overflow occurs when calling a hardened libc function, the
automatic bounds checking will safely shutdown the program and
prevent memory corruption.

Android is experimenting with _FORTIFY_SOURCE=3, a new fortify
level which enhances memcpy() to prevent overflowing an element
of a struct. Under the enhancements, code such as

  struct foo {
    char empty[0];
    char one[1];
    char a[10];
    char b[10];
  };

  int main() {
    foo myfoo;
    int n = atoi("11");
    memcpy(myfoo.a, "01234567890123456789", n);
    return 0;
  }

will cleanly crash when the memcpy() call is made.

Fixup hostap code to support the new level. Specifically:

* Fixup sha1_transform so it works with the enhanced bounds checking.
The old memcpy() code was attempting to write to context.h0, but that
structure element is too small and the write was extending (by design)
into h1, h2, h3, and h4. Use explicit assignments instead of
overflowing the struct element.

* Modify most of the structures in ieee802_11_defs.h to use ISO C99
flexible array members (https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html)
instead of a zero length array. Zero length arrays have zero length,
and any attempt to call memcpy() on such elements will always overflow.
Flexible array members have no such limitation. The only element not
adjusted is probe_req, since doing so will generate a compile time error,
and it's not obvious to me how to fix it.

Signed-off-by: Nick Kralevich <nnk@google.com>
9 years agoAP: Enable multicast snooping on bridge if ProxyARP IPv6 is in use
Jouni Malinen [Fri, 10 Apr 2015 14:06:25 +0000 (17:06 +0300)]
AP: Enable multicast snooping on bridge if ProxyARP IPv6 is in use

This is needed to allow correct ProxyARP behavior for IPv6.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoFix CONFIG_AP=y build without CONFIG_CTRL_IFACE
Jouni Malinen [Sat, 4 Apr 2015 08:56:53 +0000 (11:56 +0300)]
Fix CONFIG_AP=y build without CONFIG_CTRL_IFACE

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoFix compilation issues with CONFIG_NO_CONFIG_WRITE=y
Jouni Malinen [Sat, 4 Apr 2015 08:52:03 +0000 (11:52 +0300)]
Fix compilation issues with CONFIG_NO_CONFIG_WRITE=y

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agotests: INTERFACE_ADD/REMOVE with vif without creation/removal
Jouni Malinen [Sat, 4 Apr 2015 08:02:22 +0000 (11:02 +0300)]
tests: INTERFACE_ADD/REMOVE with vif without creation/removal

This is also a regression test for INTERFACE_ADD parsing.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoFix INTERFACE_ADD parsing
Ben Greear [Fri, 3 Apr 2015 23:34:33 +0000 (19:34 -0400)]
Fix INTERFACE_ADD parsing

This fixes a regression caused by commit
efa232f9159e33e18ed624906b0093e11ddcf78e ('Add support for virtual
interface creation/deletion') for the case where an empty extra argument
is included.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agohlr_auc_gw: Allow Milenage RES length to be reduced
Jouni Malinen [Fri, 3 Apr 2015 09:44:03 +0000 (12:44 +0300)]
hlr_auc_gw: Allow Milenage RES length to be reduced

Some USIM use shorter RES length than the 64-bit default from Milenage.
Such cases did not interoperate with the hlr_auc_gw implementation. Make
it possible to configure the RES length 4..8 octets, i.e., 32 to 64
bits) to support such USIM.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agowpa_cli: Fix a typo in usage text
Ola Olsson [Thu, 26 Mar 2015 23:03:21 +0000 (00:03 +0100)]
wpa_cli: Fix a typo in usage text

Signed-off-by: Ola Olsson <ola.olsson@sonymobile.com>
9 years agowpa_supplicant: Clear blacklist on connect
Jason Abele [Fri, 3 Apr 2015 00:30:48 +0000 (17:30 -0700)]
wpa_supplicant: Clear blacklist on connect

It has been noticed that the band steering/load balancing of some
multi-AP networks will lead to an ever-growing list of blacklisted
BSSIDs. This eventually leads to a connection drop when the connection
is pushed to a distant AP.

Fix this issue by clearing the blacklist upon successful connect.

Signed-off-by: Jason Abele <jason@aether.com>
9 years agoAndroid: wpa_ctrl missing include for sys/stat.h
Mark Salyzyn [Wed, 1 Apr 2015 00:58:11 +0000 (17:58 -0700)]
Android: wpa_ctrl missing include for sys/stat.h

wpa_ctrl.c gets sys/stat.h inherited from
private/android_filesystem_config.h it should
not rely on this in the future. The intent is
to move fs_config function into libcutils and
thus deprecate any need for sys/stat.h in this
include file.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
9 years agoHS 2.0R2: Allow user to specify spp.xsd file location
Ben Greear [Wed, 1 Apr 2015 00:14:20 +0000 (20:14 -0400)]
HS 2.0R2: Allow user to specify spp.xsd file location

Allow user to specify the path to the spp.xsd file for hs20-osu-client
instead of requiring this to be spp.xsd in the current working
directory.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agoHS 2.0R2: Add more debugging messages to hs20-osu-client
Ben Greear [Wed, 1 Apr 2015 00:14:19 +0000 (20:14 -0400)]
HS 2.0R2: Add more debugging messages to hs20-osu-client

Helps to figure out why some errors happen.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agoHS 2.0R2 CA: Improve setup.sh and .conf for more flexibility
Ben Greear [Wed, 1 Apr 2015 00:14:17 +0000 (20:14 -0400)]
HS 2.0R2 CA: Improve setup.sh and .conf for more flexibility

This gives more flexibility when generating keys so that users do not
have to edit files to generate their own specific keys.

Update HS 2.0 OSU server notes as well.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agoReschedule scan from wpas_stop_pno if it was postponed
Dmitry Shmidt [Mon, 30 Mar 2015 20:44:11 +0000 (13:44 -0700)]
Reschedule scan from wpas_stop_pno if it was postponed

This reschedules the postponed scan request (if such a request is
pending) from EVENT_SCHED_SCAN_STOPPED event handler to speed up
scanning after PNO/sched_scan stop has been requested.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
9 years agoEAP-PEAP server: Add support for negotiating vendor for Phase 2
Jouni Malinen [Wed, 1 Apr 2015 09:36:33 +0000 (12:36 +0300)]
EAP-PEAP server: Add support for negotiating vendor for Phase 2

This is a step towards enabling support of expanded EAP header in Phase
2.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoEAP peer: Use 32-bit EAP method type for Phase 2 processing
Jouni Malinen [Wed, 1 Apr 2015 09:35:14 +0000 (12:35 +0300)]
EAP peer: Use 32-bit EAP method type for Phase 2 processing

This is a step towards enabling expanded EAP header within Phase 2 EAP
methods.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agotests: EAP-TTLS with TLS session ticket enabled
Jouni Malinen [Tue, 31 Mar 2015 16:40:41 +0000 (19:40 +0300)]
tests: EAP-TTLS with TLS session ticket enabled

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoFix a typo in configuration parameter documentation
Jouni Malinen [Tue, 31 Mar 2015 16:40:08 +0000 (19:40 +0300)]
Fix a typo in configuration parameter documentation

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoTLS: Fix memory leaks on tls_connection_set_params() error paths
Jouni Malinen [Tue, 31 Mar 2015 13:17:48 +0000 (16:17 +0300)]
TLS: Fix memory leaks on tls_connection_set_params() error paths

The internal TLS implementation started rejecting number of unsupported
configuration parameters recently, but those new error paths did not
free the allocated tlsv1_credentials buffer.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoMake tls_connection_get_keyblock_size() internal to tls_*.c
Jouni Malinen [Tue, 31 Mar 2015 13:15:39 +0000 (16:15 +0300)]
Make tls_connection_get_keyblock_size() internal to tls_*.c

This function exposes internal state of the TLS negotiated parameters
for the sole purpose of being able to implement PRF for EAP-FAST. Since
tls_connection_prf() is now taking care of all TLS-based key derivation
cases, it is cleaner to keep this detail internal to each tls_*.c
wrapper implementation.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoRemove master key extraction from tls_connection_get_keys()
Jouni Malinen [Tue, 31 Mar 2015 12:52:40 +0000 (15:52 +0300)]
Remove master key extraction from tls_connection_get_keys()

This is not needed anymore with the tls_connection_prf() being used to
handle all key derivation needs. tls_connection_get_keys() is a bit
misnamed for now, but it is only used to fetch the client and server
random for Session-Id derivation.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoUse tls_connection_prf() for all EAP TLS-based key derivation
Jouni Malinen [Tue, 31 Mar 2015 12:47:32 +0000 (15:47 +0300)]
Use tls_connection_prf() for all EAP TLS-based key derivation

tls_openssl.c is the only remaining TLS/crypto wrapper that needs the
internal PRF implementation for EAP-FAST (since
SSL_export_keying_material() is not available in older versions and does
not support server-random-before-client case). As such, it is cleaner to
assume that TLS libraries support tls_connection_prf() and move the
additional support code for the otherwise unsupported cases into
tls_openssl.c.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoRename HT 20/40 coex variable to be more descriptive
Jouni Malinen [Mon, 30 Mar 2015 09:58:41 +0000 (12:58 +0300)]
Rename HT 20/40 coex variable to be more descriptive

is_ht_allowed is a confusing name since this variable is used to track
whether 40 MHz channel bandwidth is allowed instead of whether HT is
allowed in general.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
9 years agoEAP server: Add debug prints to help asleap testing
Jouni Malinen [Sun, 29 Mar 2015 19:49:16 +0000 (22:49 +0300)]
EAP server: Add debug prints to help asleap testing

This adds hexdumps of MSCHAP/MSCHAPv2 Challenge and Response in format
used by asleap. This is only enabled for CONFIG_TESTING_OPTIONS=y
builds.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoAdd wpa_snprintf_hex_sep()
Jouni Malinen [Sun, 29 Mar 2015 19:27:43 +0000 (22:27 +0300)]
Add wpa_snprintf_hex_sep()

This can be used to print a hexdump with the specified separator between
octets.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoms_funcs: Make challenge_hash() non-static
Jouni Malinen [Sun, 29 Mar 2015 19:27:00 +0000 (22:27 +0300)]
ms_funcs: Make challenge_hash() non-static

This function can be of use outside ms_funcs.c.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agotests: EAP-PEAP/MSCHAPv2 with domain name
Jouni Malinen [Sun, 29 Mar 2015 19:06:06 +0000 (22:06 +0300)]
tests: EAP-PEAP/MSCHAPv2 with domain name

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoP2P: Optimize scan frequencies list when re-joining a persistent group
Avraham Stern [Sun, 29 Mar 2015 10:10:36 +0000 (13:10 +0300)]
P2P: Optimize scan frequencies list when re-joining a persistent group

When starting a P2P client to re-join a persistent group
(P2P_GROUP_ADD persistent=<id>), it is possible that the P2P GO was
already found in previous scans. Try to get the P2P GO operating
frequency from the scan results list so wpa_supplicant will initially
scan only the P2P GO known operating frequency.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
9 years agohostapd: Fix some compilation errors
Eliad Peller [Sun, 29 Mar 2015 12:03:25 +0000 (15:03 +0300)]
hostapd: Fix some compilation errors

If NEED_AP_MLME=y is not defined, compilation might
fail under some configurations:

src/ap/drv_callbacks.c:594:2: warning: implicit declaration of
function ‘hostapd_acs_completed’ [-Wimplicit-function-declaration]

src/ap/sta_info.c:253: undefined reference to `sae_clear_retransmit_timer'

Fix these errors by adding the missing hostapd_acs_completed() stub,
and defining NEED_AP_MLME in case of CONFIG_SAE.

Signed-off-by: Eliad Peller <eliad@wizery.com>
9 years agoAdd support for CONFIG_NO_ROAMING to Makefile
Lauri Hintsala [Fri, 20 Mar 2015 18:46:03 +0000 (20:46 +0200)]
Add support for CONFIG_NO_ROAMING to Makefile

Commit e9af53ad39a19264bf5307a1b5923afc2b2f9b06 introduced new
CONFIG_NO_ROAMING configuration parameter but unfortunately it was added
only to Android.mk. Enabling this parameter didn't have any effect when
Makefile was used to build wpa_supplicant. This commit fixes that problem
and cleans "unused variable" compiler warning.

Signed-off-by: Lauri Hintsala <lauri.hintsala@silabs.com>
9 years agoOpenSSL: Implement AES-128 CBC using EVP API
Jouni Malinen [Sun, 29 Mar 2015 17:30:58 +0000 (20:30 +0300)]
OpenSSL: Implement AES-128 CBC using EVP API

This replaces the internal CBC mode implementation in
aes_128_cbc_encrypt() and aes_128_cbc_decrypt() with the OpenSSL
implementation for CONFIG_TLS=openssl builds.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoExplicitly clear temporary stack buffers in tls_prf_sha1_md5()
Jouni Malinen [Sun, 29 Mar 2015 13:43:03 +0000 (16:43 +0300)]
Explicitly clear temporary stack buffers in tls_prf_sha1_md5()

The local buffers may contain information used to generate parts of the
derived key, so clear these explicitly to minimize amount of unnecessary
private key-related material in memory.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoExplicitly clear temporary stack buffer in sha1_t_prf()
Jouni Malinen [Sun, 29 Mar 2015 13:40:55 +0000 (16:40 +0300)]
Explicitly clear temporary stack buffer in sha1_t_prf()

The local hash[] buffer may contain parts of the derived key, so clear
it explicitly to minimize number of unnecessary copies of key material
in memory.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoExplicitly clear temporary stack buffer in hmac_sha256_kdf()
Jouni Malinen [Sun, 29 Mar 2015 13:38:37 +0000 (16:38 +0300)]
Explicitly clear temporary stack buffer in hmac_sha256_kdf()

The local T[] buffer may contain parts of the derived key, so clear it
explicitly to minimize number of unnecessary copies of key material in
memory.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agowext: Add support for renamed Host AP driver ifname
Jouni Malinen [Sun, 29 Mar 2015 08:42:02 +0000 (11:42 +0300)]
wext: Add support for renamed Host AP driver ifname

Previous workaround for WEXT events from the Host AP driver required
wlan# and wifi# interfaces to have fixed names with the same number.
While that used to be the common case ten years ago, it is less common
nowadays. Extend this to use sysfs (if available) to figure out the
wifi# interface name if the specified interface is detected to be using
the Host AP driver.

Signed-off-by: Jouni Malinen <j@w1.fi>
9 years agoImprove error messages related to EAP DB
Ben Greear [Thu, 26 Mar 2015 21:39:57 +0000 (17:39 -0400)]
Improve error messages related to EAP DB

Add SQLite error message and DB name to the DB related errors. Add
enough tracing so that users can know exactly where users are failing to
be found.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agoError out if user configures SQLite DB without CONFIG_SQLITE
Ben Greear [Thu, 26 Mar 2015 21:39:56 +0000 (17:39 -0400)]
Error out if user configures SQLite DB without CONFIG_SQLITE

This should make it more obvious to users that they have a fatal
configuration problem in hostapd authentication server.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agoHS 2.0R2: Add more logging for hs20-osu-client icon matching
Ben Greear [Thu, 26 Mar 2015 21:39:55 +0000 (17:39 -0400)]
HS 2.0R2: Add more logging for hs20-osu-client icon matching

Add some more verbose logging, and make sure logging
messages are unique for easier debugging.

Signed-off-by: Ben Greear <greearb@candelatech.com>
9 years agoOSU server: Improve logging for SPP schema validation failures
Ben Greear [Thu, 26 Mar 2015 21:39:53 +0000 (17:39 -0400)]
OSU server: Improve logging for SPP schema validation failures

Signed-off-by: Ben Greear <greearb@candelatech.com>