Jouni Malinen [Sun, 4 Jan 2015 19:45:18 +0000 (21:45 +0200)]
tests: TDLS channel switching
Verify correct behavior with invalid commands. In addition, allow minor
mac80211_hwsim modifications to be used to enable testing of the driver
interface to enable and disable channel switching.
For the start operation, this includes appropriate parameters for
specifying channel and peer information. The cancel operation includes
peer information.
Arik Nemtsov [Mon, 29 Dec 2014 03:35:20 +0000 (22:35 -0500)]
nl80211: Pass TDLS channel-switch start/stop params to kernel
The kernel-driver/firmware are responsible for performing periodic
switches to the target channel with the given peer. Propagate all TDLS
channel switching related information to kernel.
Arik Nemtsov [Mon, 29 Dec 2014 05:20:51 +0000 (00:20 -0500)]
TDLS: Propagate enable/disable channel-switch commands to driver
The supplicant code does not try to control the actual channel of the
radio at any point. It simply passes the target peer and channel
parameters to the driver. It's the driver's responsibility to
periodically initiate TDLS channel-switch operations when TDLS
channel-switching is enabled.
Allow enable/disable operations to be invoked via the control interface.
Eliad Peller [Mon, 29 Dec 2014 02:15:02 +0000 (21:15 -0500)]
tests: wmm_ac_status and roaming case with WMM-AC
Make sure the wmm_ac_status command reflects correctly the existing
tspecs after add_ts/del_ts commands. Add a new test to verify all tspecs
are removed on roaming (while FT is not used).
Eliad Peller [Mon, 29 Dec 2014 02:15:01 +0000 (21:15 -0500)]
WMM AC: Reconfigure tspecs on reassociation to the same BSS
The specification requires the tspecs to be kept upon reassociation to
the same BSS. Save the last tspecs before such reassociation, and
reconfigure on the association notification.
Note that the current flow is not transparent to the user
(it is notified about deauth/reassoc and tspec removal/addition).
Eliad Peller [Mon, 29 Dec 2014 02:15:00 +0000 (21:15 -0500)]
WMM AC: Do not fail on unknown IEs in Association Response
Some APs add their custom (vendor-specific) IEs to the Association
Response frame. Fail WMM AC initialization only if Association Response
frame IE parsing actually failed, i.e., ignore all unknown IEs.
If registering WMM-AC ADDTS response action frame or WMM-AC DELTS
action frame fails, the management frame handler is not being
registered. This results with a segmentation fault when trying to
unsubscribe the handler when the interface is removed.
Fix it by always registering the handler and just returning a negative
value to note that the action frame could not be registered.
Jouni Malinen [Sat, 3 Jan 2015 13:57:41 +0000 (15:57 +0200)]
doc: Add rule for generating _wpa_supplicant.eps
Commit 7c4e92115a795dd2ee2135cf49d7e9e172fb5851 ('Update Doxygen
documentation for new version') rename the PNG version of the image, but
forgot the EPS version for Latex.
Jouni Malinen [Sat, 3 Jan 2015 13:44:35 +0000 (15:44 +0200)]
doc: Disable Doxygen autolink support
The way autolink support is implementing in Doxygen is a bit
inconvenient with wpa_supplicant being recognized as something that
would always be linked to struct wpa_supplicant. In addition, number of
links were not really noticed automatically. To get this working more
robustly and without having to use the %wpa_supplicant workaround (which
had its own issues, e.g., with titles), disable autolinking and use
explicit \ref commands instead.
This is also updating some of the obsolete notes to point to correct
file names, etc. changes in the source code tree.
Jouni Malinen [Fri, 2 Jan 2015 23:01:42 +0000 (01:01 +0200)]
nl80211: Clear nlmsg payload with keys before freeing
This reduces the time possible keys could remain in heap memory. Couple
of the nl80211 messages include keys (TK for normal ciphers and
KCK/KEK/PMK for various offloading cases).
Jouni Malinen [Fri, 2 Jan 2015 20:54:30 +0000 (22:54 +0200)]
nl80211: Note linux_set_iface_flags() failure in debug log
There was one final remaining linux_set_iface_flags() call that did not
check the result. This specific one does not really matter much, but
anyway, be more consistent by checking the result and log any error in
debug log. (CID 74146)
Jouni Malinen [Fri, 2 Jan 2015 20:12:38 +0000 (22:12 +0200)]
tests: Make wpas_mesh_max_peering more robust
The previous version was enabling all three stations at the same time
and left dev[1] and dev[2] competing on getting connected with dev[0]
that allowed only one pairing. This was not exactly robust and the pass
criteria depended on an extra event from either dev[1] or dev[2]. Fix
that by first connecting dev[0] and dev[1] and only after that, start
dev[2]. This allows proper validation of both the peering limit on
dev[0] and no extra event on dev[2].
Jouni Malinen [Fri, 2 Jan 2015 16:21:25 +0000 (18:21 +0200)]
tests: Make scan_hidden more robust under heavy CPU load
It is possible for the Probe Response frame wait to time out when active
scanning is used under heavy CPU load. Make this test case more robust
by trying multiple times before declaring the scan for a hidden SSID to
have failed.
Jouni Malinen [Fri, 26 Dec 2014 15:44:24 +0000 (17:44 +0200)]
tests: Enable wpa_supplicant D-Bus support for hwsim tests
This allows automated testing of the wpa_supplicant D-Bus interface. The
instance controlling wlan0 registers with D-Bus if dbus-daemon was
started successfully. This is only used in VM testing, i.e., not when
run-tests.sh is used on the host system with D-Bus running for normal
system purposes.
Jouni Malinen [Wed, 31 Dec 2014 10:18:43 +0000 (12:18 +0200)]
doc: Document the D-Bus P2P extensions
P2P support was added to the wpa_supplicant D-Bus interface long time
ago, but there has been no attempt of documenting that interface so far.
This commit adds at least a list of new interfaces, methods, properties,
and signals. Some of the incorrect and/or strange parts of the interface
are also identified with bug/todo comments.
Jouni Malinen [Fri, 2 Jan 2015 15:11:15 +0000 (17:11 +0200)]
D-Bus: Fix WPS.Start method in AP/P2P GO mode
Previously, role="enrollee" was required to be used to allow the AP mode
WPS operation to be started. This is incorrect since the AP/GO will
operate in Registrar role. Fix this by ignoring the role parameter when
AP (including P2P GO) mode is enabled.
Jouni Malinen [Fri, 2 Jan 2015 15:09:38 +0000 (17:09 +0200)]
WPS: Reject station-mode WPS operations when AP mode is enabled
Start of station-mode WPS PBC/PIN/Registrar/NFC operation would result
in the AP mode getting disabled. This can be particularly confusing for
the P2P GO case where the group would need to be stopped cleanly. As
such, it is better to reject these invalid operations rather than trying
to handle all corner cases needed to allow this to work robustly.
Jouni Malinen [Fri, 2 Jan 2015 10:25:32 +0000 (12:25 +0200)]
D-Bus: Make P2P Group Passphrase property getter available for P2P Client
There is no need to limit this property based on the role of the device
in the group, so return the passphrase if it is available. It will be
available in GO role and it may be available in P2P Client role based on
whether the peer GO provided it during the WPS provisioning step.
Jouni Malinen [Fri, 2 Jan 2015 10:20:44 +0000 (12:20 +0200)]
D-Bus: Fix P2P Group PSK property getter
This was returning a byte array of the pointer to the PSK, not the
actual PSK, due to incorrect use of
wpas_dbus_simple_array_property_getter(). In addition, there is no need
to limit this property based on the role of the device in the group, so
return the PSK if it is available (which it will be for both GO and P2P
Client roles).
Jouni Malinen [Thu, 1 Jan 2015 20:36:52 +0000 (22:36 +0200)]
D-Bus: Simplify out-of-memory reporting
There is no need to have separate wpa_printf() and different error
message strings for the unlikely out-of-error messages. Use a helper
function, wpas_dbus_error_no_memory(), to get consistent behavior with a
one-line call.
Jouni Malinen [Thu, 1 Jan 2015 20:16:34 +0000 (22:16 +0200)]
D-Bus: Remove the obsolete notes from wpas_dbus_error_unknown_error()
Commit 6aeeb6fa21bc072ba92ce9423ba5c0417e8c0bf5 ('dbus: clean up new
D-Bus interface getters and setters') redesigned the property
getter/setter calls in a way that made the
wpas_dbus_error_unknown_error() note about message being NULL in some
cases obsolete. All the remaining callers are from method handler
functions that must have a valid message. Remove the obsolete notes and
unnecessary messsage == NULL check.
Jouni Malinen [Wed, 31 Dec 2014 11:57:48 +0000 (13:57 +0200)]
D-Bus: Simplify message building error paths
There is no need to have multiple separate return statements for error
cases in a sequence of operations. In addition, there is not much point
in "converting" boolean return values with "if (!res) return FALSE;
return TRUE;" style constructions.
net_id_str can be NULL and that must be checked for to avoid NULL
pointer dereference if an invalid persistent_group_object path is used
with these methods.
Jouni Malinen [Thu, 1 Jan 2015 09:42:32 +0000 (11:42 +0200)]
D-Bus: Clean up wpas_dbus_new_decompose_object_path()
None of the new D-Bus interface cases use the bssid_part in
decompose_object_path (while the old interface ones do). As such, this
is dead code and can be removed. In addition, the P2P addition here was
pretty ugly extension. Replace these with a cleaner way of passing the
separating string (e.g., "Networks") from the caller and returning the
requested item.
In addition, there is no need to allocate the returned item separately,
so use a single allocation and a pointer to that allocated memory. This
will make it easier for callers to have to free only a single
allocation. This is also fixing a memory leak in P2P invitation
persistent group case where the caller had missed the need to free the
returned values.
Jouni Malinen [Thu, 1 Jan 2015 13:24:08 +0000 (15:24 +0200)]
D-Bus: Clean up parse_peer_object_path() uses
This helper function does not modify peer_path, so mark it const. In
addition, there is no point in callers to check separately whether
peer_path is NULL since that is taken care of by this helper function.
Jouni Malinen [Thu, 1 Jan 2015 00:10:37 +0000 (02:10 +0200)]
D-Bus: Remove useless wpa_s->conf checks
This cannot be NULL when an interface is in use. There is not much point
in couple of functions checking this while large number of other places
do not.
Jouni Malinen [Wed, 31 Dec 2014 14:54:48 +0000 (16:54 +0200)]
D-Bus (old): Fix removeNetwork method to not use freed memory
wpa_supplicant_deauthenticate() call needs to happen before
wpa_config_remove_network(). Freed memory could be dereferenced if
removeNetwork method was issued on the currently connected network.
Jouni Malinen [Wed, 31 Dec 2014 14:40:14 +0000 (16:40 +0200)]
D-Bus: Avoid valgrind warning due to compiler optimization
It looks like both gcc and clang optimize the (entry.type != foo ||
entry.array_type != bar) in a way that ends up evaluating the second
condition even when the first one results in 0. While this is not really
what the C language requirements on short-circuit evaluation require,
the compiler likely assumes this can have no side effects and with both
type and array_type being comparable in a single 64-bit operation, this
can clearly be a bit more efficient. While the code behaves same in both
cases, valgrind does warn about use of uninitialized memory when the
second condition is evaluated (entry.array_type is not initialized if
entry.type != DBUS_TYPE_ARRAY).
To keep valgrind logs cleaner, initialize entry.array_type to
DBUS_TYPE_INVALID so that these compiler optimizations do not result in
reading uninitialized memory.
Jouni Malinen [Wed, 31 Dec 2014 14:33:35 +0000 (16:33 +0200)]
D-Bus: Avoid compiler warning on sometimes uninitialized variable
The logic in wpas_dbus_signal_p2p_provision_discovery() seemed to imply
that there could be a case where _signal would be used uninitized. While
that is not the case since either (request || !status) or (!request &&
status) would always be true, some compilers do not seem to be clever
enough to figure that out to avoid the warning. Make this easier for
such compilers by removing the (!request && status) condition since it
is identical to !(request || !status).
Jouni Malinen [Wed, 31 Dec 2014 13:46:08 +0000 (15:46 +0200)]
D-Bus: Make WPAS_DBUS_TYPE_BINARRAY value less confusing
Commit 911e97e4002019e577bb1086f1fd02daff978544 ('DBus: Refactor array
adding, add binary arrays') introduced WPAS_DBUS_TYPE_BINARRAY as an
internal fake type for array_type. However, it selected this value to be
(DBUS_NUMBER_OF_TYPES + 100) = 116 = 't'. This happens to conflict with
DBUS_TYPE_UINT64 ((int) 't'). While none of the existing array_type use
cases supported UINT64, it is much clearer if WPAS_DBUS_TYPE_BINARRAY
has a value that does not match any existing DBUS_TYPE_* value. Replace
this with '@' (64).
Jouni Malinen [Wed, 31 Dec 2014 11:32:47 +0000 (13:32 +0200)]
D-Bus: Fix dict binarray getter to accept empty array of array
This is needed to allow Set(P2PDeviceConfig) to clear the
VendorExtension array (i.e., to remove all configured vendor
extensions). Previously, such an attempt was met with a D-Bus assert and
rejection of the operation.
Jouni Malinen [Wed, 31 Dec 2014 11:05:51 +0000 (13:05 +0200)]
D-Bus: Fix memory leak on P2PDeviceConfig::VendorExtension
The wps_vendor_ext array can be set using D-Bus Set(P2PDeviceConfig)
with the VendorExtension key in the dictionary. However, there was no
code for freeing the allocated memory when the interface is removed.
Jouni Malinen [Wed, 31 Dec 2014 08:45:50 +0000 (10:45 +0200)]
D-Bus: Fix ServiceDiscoveryResponse to accept int32 dialog_token
The ServiceDiscoveryRequest signal uses int32 for encoding dialog_token
for some reason (even though this is a u8 field).
ServiceDiscoveryResponse is supposed to accept the values from the
signal as-is, so extend that to accept int32 in addition to the
previously used uint32.
Jouni Malinen [Tue, 30 Dec 2014 20:20:00 +0000 (22:20 +0200)]
D-Bus: Fix .Group Set(WPSVendorExtensions) format
The earlier implementation seemed to require a strange extra
encapsulation with a dictionary for setting the WPSVendorExtensions
property while this was defined to have aay signature and the get
operation did indeed return and array of array of bytes without that
dictionary. Fix this to accept aay format for the setter as well. Keep
support for the old dictionary encapsulation format for backwards
compatibility.
Jouni Malinen [Tue, 30 Dec 2014 19:04:07 +0000 (21:04 +0200)]
D-Bus: Fix memory leak on P2P GO WPSVendorExtensions
It was possible to add WPS vendor extensions through the D-Bus
WPSVendorExtensions setter, but these extensions were not freed when the
P2P GO was stopped or when replacing previously configured extensions.
Jouni Malinen [Mon, 29 Dec 2014 16:40:10 +0000 (18:40 +0200)]
SAE: Clear keys from memory on disassociation
There is no need to keep temporary keys in memory beyond the end of the
association, so explicitly clear any SAE buffers that can contain keys
as soon as such keys are not needed.
Jouni Malinen [Mon, 29 Dec 2014 13:41:03 +0000 (15:41 +0200)]
Clear GTK from memory as soon as it is not needed anymore
It was possible for the decrypted EAPOL-Key Key Data field to remain in
heap after the temporary buffer was freed. Explicitly clear that buffer
before freeing it to minimize the time GTK remains in memory.
Jouni Malinen [Mon, 29 Dec 2014 11:11:29 +0000 (13:11 +0200)]
Clear psk_list while freeing config_ssid instances
Previously, the main PSK entry was cleared explicitly, but psk_list
could include PSKs for some P2P use cases, so clear it as well when
freeing config_ssid instances.
Jouni Malinen [Mon, 29 Dec 2014 11:05:32 +0000 (13:05 +0200)]
Clear wpa_psk memory when setting up wpa_supplicant AP mode
This is more of a theoretical case since this part is done only during
setup and the structure is not allocated in practice. Anyway,
maintaining more consistent use of bin_clear_free() for structures that
may contain keys is useful.
Jouni Malinen [Mon, 29 Dec 2014 11:03:01 +0000 (13:03 +0200)]
Clear TK part of PTK after driver key configuration
There is no need for wpa_supplicant to maintain a copy of the TK part of
PTK after this has been configured to the driver, so clear that from
heap memory and only maintain KEK and KCK during association to allow
additional EAPOL-Key handshakes.
Jouni Malinen [Mon, 29 Dec 2014 11:00:03 +0000 (13:00 +0200)]
Clear temporary keys from WPA supplicant state machine when not needed
PMK and PTK are not needed in the supplicant state machine after
disassociation since core wpa_supplicant will reconfigure them for the
next association. As such, clear these from heap in
wpa_sm_notify_disassoc() to reduce time and number of places storing key
material in memory. In addition, clear FT keys in case of
CONFIG_IEEE80211R=y build (sm->xxkey stored a copy of PSK in case of
FT-PSK).
Jouni Malinen [Mon, 29 Dec 2014 15:22:17 +0000 (17:22 +0200)]
tests: Filter out extra files from codecov reports
wpa_cli and hostapd_cli are not currently tested for code coverage, so
filter the files specific to those components away from the code
coverage reports. *_module_tests.c are not included in normal builds, so
drop them as well. In addition, drop the system header file (byteswap.h)
that gets somehow unnecessarily included in the reports for couple of
lines.
Jouni Malinen [Sun, 28 Dec 2014 17:30:26 +0000 (19:30 +0200)]
doc: Add D-Bus SignalPoll() method
Commit 7a4a93b9593575ffd64ba72739429d98e4b90858 ('dbus: Add SignalPoll()
method to report current signal properties') added this method, but
forgot to document it.
Jouni Malinen [Sun, 28 Dec 2014 16:07:09 +0000 (18:07 +0200)]
doc: Add D-Bus global Capabilities property
This property was added to the fi.w1.wpa_supplicant1 interface in commit 1634ac0654eba8d458640a115efc0a6cde3bac4d ('dbus: Add global capabilities
property'), but documentation was not updated.
Jouni Malinen [Sun, 28 Dec 2014 15:03:18 +0000 (17:03 +0200)]
doc: Fix D-Bus page format with newer Doxygen versions
It looks like the space indentation before the HTML command ended up
being converted to HTML tags getting shown as code text rather than
being used to control formatting. Fix this by removing indentation from
the first line of each HTML segment.
Jouni Malinen [Sat, 27 Dec 2014 20:50:17 +0000 (22:50 +0200)]
D-Bus(old): Fix removeNetwork and selectNetwork error handling
wpas_dbus_decompose_object_path() may leave the network part NULL on
unexpected path. This resulted in NULL pointer dereference when
processing an invalid removeNetwork or selectNetwork call. Fix this by
explicitly verifying that the network part was included in the object
path.
Jouni Malinen [Sat, 27 Dec 2014 19:00:11 +0000 (21:00 +0200)]
D-Bus: Fix P2P persistent group removal from non-D-Bus triggers
It is possible for the persistent group object to be added and removed
by non-D-Bus triggers (e.g., ctrl_iface commands). The add part was
already handled, but removal was not. That resulted in memory leaks when
a P2P persistent group was removed without using an explicit D-Bus
command for this even if the object was added without D-Bus involvement.
Jouni Malinen [Fri, 26 Dec 2014 17:57:24 +0000 (19:57 +0200)]
D-Bus: Fix WPS ConfigMethods getter to handle no value properly
wpas_dbus_simple_property_getter() cannot be used with NULL
DBUS_TYPE_STRING, so replace that with an empty string to handle the
case of no config_methods parameter in the configuration.
Jouni Malinen [Fri, 26 Dec 2014 16:19:36 +0000 (18:19 +0200)]
D-Bus: Fix P2P peer joined/disconnected handlers
It is possible for the peer to be a non-P2P device and as such, for
p2p_dev_addr to be NULL. This resulted in NULL pointer dereference if
D-Bus interface was enabled for the interface when a legacy STA joined a
group.
Jouni Malinen [Sat, 27 Dec 2014 13:37:13 +0000 (15:37 +0200)]
Clear next_scan_freqs on wpa_supplicant FLUSH command
It was possible for old scan state to remain from a previous test case
when an operation like WNM neighbor scan or another-BSS-in-ESS was
started, but stopped at the end of a test case. This could result in
failures, e.g., when running wnm_bss_tm_req followed by scan_setband.
Paul Stewart [Thu, 4 Dec 2014 22:23:35 +0000 (14:23 -0800)]
hostapd: Set stdout line-buffered
If hostapd will use stdout for debugging, set stdout to be line
buffered in case its output is redirected to a file. This allows
incremental output to be viewed immediately instead of at the file
buffering interval.
David Woodhouse [Thu, 18 Dec 2014 15:09:55 +0000 (15:09 +0000)]
OpenSSL: Do not require a PIN for PKCS#11
It isn't mandatory. If we need one and it's not present, the ENGINE will
try asking for it. Make sure it doesn't actually let an OpenSSL UI loose,
since we don't currently capture those.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
David Woodhouse [Thu, 18 Dec 2014 15:09:47 +0000 (15:09 +0000)]
OpenSSL: Automatically enable PKCS#11 engine where it's needed
It needs to be available to ENGINE_by_id(), which in my case means it
needs to be /usr/lib64/openssl/engines/libpkcs11.so. But that's a system
packaging issue. If it isn't there, it will fail gracefully enough with:
ENGINE: engine pkcs11 not available [error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library]
TLS: Failed to set TLS connection parameters
EAP-TLS: Failed to initialize SSL.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
David Woodhouse [Thu, 18 Dec 2014 15:09:40 +0000 (15:09 +0000)]
OpenSSL: Load dynamic ENGINE unconditionally
This means that if the PKCS#11 engine is installed in the right place
in the system, it'll automatically be invoked by ENGINE_by_id("pkcs11")
later, and things work without explictly configuring pkcs11_engine_path.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
David Woodhouse [Thu, 18 Dec 2014 15:09:32 +0000 (15:09 +0000)]
OpenSSL: Automatically handle PKCS#11 URIs in private_key, ca/client_cert
If these start with "pkcs11:" then they are PKCS#11 URIs. These Just Work
in the normal private_key/ca_cert/client_cert configuration fields when
built with GnuTLS; make it work that way with OpenSSL too.
(Yes, you still need to explicitly set engine=1 and point to the engine,
but I'll work on that next...)
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
David Woodhouse [Thu, 18 Dec 2014 15:09:16 +0000 (15:09 +0000)]
OpenSSL: Allow pkcs11_module_path to be NULL
New versions of engine_pkcs11 will automatically use the system's
p11-kit-proxy.so to make the globally-configured PKCS#11 tokens available
by default. So invoking the engine without an explicit module path is
not an error.
Older engines will fail but gracefully enough, so although it's still an
error in that case there's no need for us to catch it for ourselves.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>