]> git.ipfire.org Git - thirdparty/hostap.git/log
thirdparty/hostap.git
10 years agoCheck os_snprintf() result more consistently - more checks
Jouni Malinen [Sun, 7 Dec 2014 13:45:02 +0000 (15:45 +0200)] 
Check os_snprintf() result more consistently - more checks

Add more os_snprintf() result validation checks.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently
Jouni Malinen [Sat, 6 Dec 2014 19:40:31 +0000 (21:40 +0200)] 
Check os_snprintf() result more consistently

While these are using practically large enoungh buffer sizes, it is
better to be more consistent with checking os_snprintf() return value.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - manual
Jouni Malinen [Sun, 7 Dec 2014 10:52:59 +0000 (12:52 +0200)] 
Check os_snprintf() result more consistently - manual

This converts os_snprintf() result validation cases to use
os_snprintf_error() for cases that were note covered by spatch and
semantic patches.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - automatic 3
Jouni Malinen [Mon, 8 Dec 2014 09:22:52 +0000 (11:22 +0200)] 
Check os_snprintf() result more consistently - automatic 3

This converts os_snprintf() result validation cases to use
os_snprintf_error() where the comparison was 'res > size' instead of
'res >= size - 1'. These changes were done automatically with spatch
using the following semantic patch:

@@
identifier E1;
expression E2,E3,E4,E5,E6;
statement S1;
@@

(
  E1 = os_snprintf(E2, E3, ...);
|
  int E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else if (E6)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = 0;
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else if (E6) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
E1 = os_snprintf(E2, E3, ...);
  }
)
? os_free(E4);
- if (E1 < 0 || (size_t) E1 >= E3 - 1)
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - automatic 2
Jouni Malinen [Mon, 8 Dec 2014 09:18:39 +0000 (11:18 +0200)] 
Check os_snprintf() result more consistently - automatic 2

This converts os_snprintf() result validation cases to use
os_snprintf_error() where the comparison was 'res > size' instead of
'res >= size'. These changes were done automatically with spatch using
the following semantic patch:

@@
identifier E1;
expression E2,E3,E4,E5,E6;
statement S1;
@@

(
  E1 = os_snprintf(E2, E3, ...);
|
  int E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else if (E6)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = 0;
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else if (E6) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
E1 = os_snprintf(E2, E3, ...);
  }
)
? os_free(E4);
- if (E1 < 0 || \( E1 > E3 \| (size_t) E1 > E3 \| E1 > (int) E3 \))
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - automatic 1
Jouni Malinen [Mon, 8 Dec 2014 09:15:51 +0000 (11:15 +0200)] 
Check os_snprintf() result more consistently - automatic 1

This converts os_snprintf() result validation cases to use
os_snprintf_error() where the exact rule used in os_snprintf_error() was
used. These changes were done automatically with spatch using the
following semantic patch:

@@
identifier E1;
expression E2,E3,E4,E5,E6;
statement S1;
@@

(
  E1 = os_snprintf(E2, E3, ...);
|
  int E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else if (E6)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = 0;
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else if (E6) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
E1 = os_snprintf(E2, E3, ...);
  }
)
? os_free(E4);
- if (E1 < 0 || \( E1 >= E3 \| (size_t) E1 >= E3 \| (unsigned int) E1 >= E3 \| E1 >= (int) E3 \))
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - success case
Jouni Malinen [Sun, 7 Dec 2014 10:15:34 +0000 (12:15 +0200)] 
Check os_snprintf() result more consistently - success case

This converts os_snprintf() result validation cases to use
os_snprintf_error() in cases where success condition was used to execute
a step. These changes were done automatically with spatch using the
following semantic patch:

@@
expression E1,E2,E3;
statement S1;
@@

  E1 = os_snprintf(E2, E3, ...);
- if (\( E1 >= 0 \| E1 > 0 \) && \( (size_t) E1 < E3 \| E1 < (int) E3 \| E1 < E3 \))
+ if (!os_snprintf_error(E3, E1))
  S1

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - maximum length
Jouni Malinen [Sun, 7 Dec 2014 10:11:13 +0000 (12:11 +0200)] 
Check os_snprintf() result more consistently - maximum length

This adds verification of os_snprintf() result against the maximum
buffer length. These changes were done automatically with spatch
using the following semantic patch:

@@
expression E1,E2,E3;
statement S1;
@@

  E1 = os_snprintf(E2, E3, ...);
- if (\( E1 < 0 \| E1 <= 0 \))
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoAdd os_snprintf_error() helper
Jouni Malinen [Sat, 6 Dec 2014 22:03:28 +0000 (00:03 +0200)] 
Add os_snprintf_error() helper

This can be used to check os_snprintf() return value more consistently.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoUse os_zalloc() instead of os_malloc() and os_memset()
Jouni Malinen [Sun, 7 Dec 2014 15:16:58 +0000 (17:16 +0200)] 
Use os_zalloc() instead of os_malloc() and os_memset()

Automatically updated with spatch and the following semantic patch:

@@
expression X;
expression E1;
statement S;
@@

- X = os_malloc(E1);
+ X = os_zalloc(E1);
(
  if (X == NULL) {
...
  }
- os_memset(X, 0, E1);
|
  if (X == NULL)
S
- os_memset(X, 0, E1);
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoUse os_calloc() instead of os_zalloc()
Jouni Malinen [Sun, 7 Dec 2014 14:51:38 +0000 (16:51 +0200)] 
Use os_calloc() instead of os_zalloc()

Automatic changes with spatch using the following semantic patch:

@@
constant C;
type T;
@@

- os_zalloc(C*sizeof(T))
+ os_calloc(C,sizeof(T))

@@
expression E;
type T;
@@

- os_zalloc((E)*sizeof(T))
+ os_calloc(E,sizeof(T))

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Optimize WPS tests by avoiding full scan
Jouni Malinen [Sun, 7 Dec 2014 23:37:39 +0000 (01:37 +0200)] 
tests: Optimize WPS tests by avoiding full scan

A single channel scan just before WPS_REG, WPS_PBC, and WPS_PIN commands
can be used to avoid having to run a full scan. This saves significant
amount of time in the WPS test cases.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoWPS: Start EAPOL immediately even without WPA on WPS association
Jouni Malinen [Sun, 7 Dec 2014 23:25:26 +0000 (01:25 +0200)] 
WPS: Start EAPOL immediately even without WPA on WPS association

Previously, the immediate EAPOL authenticator startup was scheduled
without having received EAPOL-Start only for the case where WPA/WPA2 was
enabled. This can be extended to speed up non-WPA/WPA2 cases as well if
the STA includes WPS IE in Association Request frame.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: P2P_GET_PASSPHRASE
Jouni Malinen [Sun, 7 Dec 2014 23:04:19 +0000 (01:04 +0200)] 
tests: P2P_GET_PASSPHRASE

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional GET_CAPABILITY coverage
Jouni Malinen [Sun, 7 Dec 2014 22:42:42 +0000 (00:42 +0200)] 
tests: Additional GET_CAPABILITY coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: SAVE_CONFIG error cases
Jouni Malinen [Sun, 7 Dec 2014 22:30:18 +0000 (00:30 +0200)] 
tests: SAVE_CONFIG error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Multiple networks and cred removal
Jouni Malinen [Sun, 7 Dec 2014 22:22:39 +0000 (00:22 +0200)] 
tests: Multiple networks and cred removal

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional DUP_NETWORK coverage
Jouni Malinen [Sun, 7 Dec 2014 22:05:55 +0000 (00:05 +0200)] 
tests: Additional DUP_NETWORK coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoFix DUP_NETWORK debug print on error case
Jouni Malinen [Sun, 7 Dec 2014 21:58:06 +0000 (23:58 +0200)] 
Fix DUP_NETWORK debug print on error case

Incorrect network id was printed in debug output if DUP_NETWORK
destination network was not found.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Add missing test descriptions
Jouni Malinen [Sun, 7 Dec 2014 21:48:05 +0000 (23:48 +0200)] 
tests: Add missing test descriptions

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant ctrl_iface mesh command error cases
Jouni Malinen [Sun, 7 Dec 2014 21:45:05 +0000 (23:45 +0200)] 
tests: wpa_supplicant ctrl_iface mesh command error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoRemove unnecessary ctrl_iface command check
Jouni Malinen [Sun, 7 Dec 2014 21:43:21 +0000 (23:43 +0200)] 
Remove unnecessary ctrl_iface command check

MESH_GROUP_REMOVE always passes in the cmd pointer, so this cannot
really be NULL.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional coverage for SCAN_RESULTS and BSS entry flags
Jouni Malinen [Sun, 7 Dec 2014 21:27:45 +0000 (23:27 +0200)] 
tests: Additional coverage for SCAN_RESULTS and BSS entry flags

This increases wpa_supplicant_ie_txt(), print_bss_info(), and
wpa_supplicant_ctrl_iface_scan_result() testing coverage to include the
previously missing key management options.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agobase64: Try to avoid static analyzer warning (part 2)
Jouni Malinen [Sun, 7 Dec 2014 20:02:57 +0000 (22:02 +0200)] 
base64: Try to avoid static analyzer warning (part 2)

Shift right on unsigned char limits the value to 0..63 which is within
bounds for base64_table[]. Anyway, some static analyzers do not seem to
understand that. See if an otherwise unnecessary masking gets rid of
false warnings. (CID 62858)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoRemove unnecessary ctrl_iface cmd check
Jouni Malinen [Sun, 7 Dec 2014 16:20:23 +0000 (18:20 +0200)] 
Remove unnecessary ctrl_iface cmd check

This pointer cannot be NULL sicne it is called only from this file and
with a valid pointer to the received command.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant ctrl_iface BSSID command error case
Jouni Malinen [Sun, 7 Dec 2014 16:19:12 +0000 (18:19 +0200)] 
tests: wpa_supplicant ctrl_iface BSSID command error case

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Check STATUS mode field during P2P group formation
Jouni Malinen [Sun, 7 Dec 2014 16:17:31 +0000 (18:17 +0200)] 
tests: Check STATUS mode field during P2P group formation

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant ctrl_iface CTRL-RSP-
Jouni Malinen [Sun, 7 Dec 2014 16:10:20 +0000 (18:10 +0200)] 
tests: wpa_supplicant ctrl_iface CTRL-RSP-

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: IBSS_RSN control interface command
Jouni Malinen [Sun, 7 Dec 2014 15:57:28 +0000 (17:57 +0200)] 
tests: IBSS_RSN control interface command

This verifies that IBSS_RSN <peer> return OK for the case where a valid
and already connection peer address is given.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant WPS_AP_PIN random PIN timeout and error caes
Jouni Malinen [Sun, 7 Dec 2014 15:47:02 +0000 (17:47 +0200)] 
tests: wpa_supplicant WPS_AP_PIN random PIN timeout and error caes

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: More coverage for WPS NFC error and uncommon cases
Jouni Malinen [Sun, 7 Dec 2014 15:36:22 +0000 (17:36 +0200)] 
tests: More coverage for WPS NFC error and uncommon cases

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Fix a typo in an error message
Jouni Malinen [Sun, 7 Dec 2014 15:24:38 +0000 (17:24 +0200)] 
tests: Fix a typo in an error message

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Remove test names from VM command with parallel-vm.py
Jouni Malinen [Sun, 7 Dec 2014 13:31:38 +0000 (15:31 +0200)] 
tests: Remove test names from VM command with parallel-vm.py

There is no need to pass the test case names to the VMs when using
parallel-vm.py. Removing those from the command line helps in avoiding
kernel panic if maximum number of kernel parameters limit is hit.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agobase64: Try to avoid static analyzer warning
Jouni Malinen [Sat, 6 Dec 2014 17:03:52 +0000 (19:03 +0200)] 
base64: Try to avoid static analyzer warning

Shift right on unsigned char limits the value to 0..63 which is within
bounds for base64_table[]. Anyway, some static analyzers do not seem to
understand that. See if an otherwise unnecessary masking gets rid of
false warnings. (CID 62858)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoInterworking: Make bounds checking easier for static analyzers
Jouni Malinen [Sat, 6 Dec 2014 16:51:23 +0000 (18:51 +0200)] 
Interworking: Make bounds checking easier for static analyzers

'num * 5 > end - pos' handles bounds checking a bit more efficiently,
but apparently that is not clear enough for all static analyzers.
Replace with 'num > left / 5' to avoid false reports. (CID 68117)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoTLS: Reorder length bounds checking to avoid static analyzer warning
Jouni Malinen [Sat, 6 Dec 2014 16:34:23 +0000 (18:34 +0200)] 
TLS: Reorder length bounds checking to avoid static analyzer warning

For some reason, "pos + len > end" is not clear enough, but "len > end -
pos" is recognized. Use that to get rid of a false positive from a
static analyzer (CID 72697).

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoEAP-SIM DB: Make recv() null termination easier for static analyzers
Jouni Malinen [Sat, 6 Dec 2014 16:28:00 +0000 (18:28 +0200)] 
EAP-SIM DB: Make recv() null termination easier for static analyzers

For some reason, the previous version was not understood to be null
terminating the buffer from recv(). It was doing this fine, though. Try
to use a bit more simpler design in hopes of getting static analyzers to
understand this. (CID 72702)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoReplace send_ft_action() driver_op with send_action()
Jouni Malinen [Sat, 6 Dec 2014 16:13:29 +0000 (18:13 +0200)] 
Replace send_ft_action() driver_op with send_action()

This reduced number of unnecessarily duplicated driver interface
callback functions for sending Action frames by using the more generic
send_action() instead of FT specific send_ft_action().

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Move scanning related functionality to a separate file
Jouni Malinen [Sat, 6 Dec 2014 15:59:26 +0000 (17:59 +0200)] 
nl80211: Move scanning related functionality to a separate file

This helps in making the still overly large driver_nl80211.c somewhat
more manageable.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agohostapd: Fix memory leak on dynamic add-BSS error path
Jouni Malinen [Sat, 6 Dec 2014 15:42:23 +0000 (17:42 +0200)] 
hostapd: Fix memory leak on dynamic add-BSS error path

If "ADD bss_config=" command failed in driver_init() or
hostapd_setup_interface(), some of the allocated resources were not
freed properly.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Clean up nl80211_scan_common() to use nl80211_cmd_msg()
Jouni Malinen [Sat, 6 Dec 2014 14:47:12 +0000 (16:47 +0200)] 
nl80211: Clean up nl80211_scan_common() to use nl80211_cmd_msg()

This helper function had not used the nl80211_set_iface_id() helper, but
there is no reason why it couldn't re-use the same helper as other
places using nl80211_cmd_msg().

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_iface_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 14:37:52 +0000 (16:37 +0200)] 
nl80211: Use nl80211_iface_msg() helper

Use the helper function to replace places that use nlmsg_alloc(),
nl80211_cmd(), and ifindex.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_bss_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 14:27:26 +0000 (16:27 +0200)] 
nl80211: Use nl80211_bss_msg() helper

Use the helper function to replace places that use nlmsg_alloc(),
nl80211_cmd(), and either bss->ifindex or if_nametoindex(bss->ifname).

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_cmd_msg() for P2P Device operations
Jouni Malinen [Sat, 6 Dec 2014 14:09:39 +0000 (16:09 +0200)] 
nl80211: Use nl80211_cmd_msg() for P2P Device operations

bss->wdev_id_set is set for the non-detdev P2P Device, so
nl80211_cmd_msg() can be used as-is for these cases as well.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_drv_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 14:05:54 +0000 (16:05 +0200)] 
nl80211: Use nl80211_drv_msg() helper

Use the helper function to replace places that use nlmsg_alloc(),
nl80211_cmd(), and drv->ifindex.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Move nl80211_set_iface_id() next its only remaining user
Jouni Malinen [Sat, 6 Dec 2014 13:17:30 +0000 (15:17 +0200)] 
nl80211: Move nl80211_set_iface_id() next its only remaining user

This function was in a bit strange location between struct family_data
and family_handler() definitions.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use the new nl80211_cmd_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 11:04:29 +0000 (13:04 +0200)] 
nl80211: Use the new nl80211_cmd_msg() helper

This removes duplicated code for building nl80211 commands for a BSS.
This commit handles the functions that were already using
nl80211_set_iface_id().

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Add nl80211_*_msg() helpers
Jouni Malinen [Sat, 6 Dec 2014 10:56:05 +0000 (12:56 +0200)] 
nl80211: Add nl80211_*_msg() helpers

These new functions can be used to both allocate and build a header for
most nl80211 commands.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Continue getting rid of NLA_PUT* macro use
Jouni Malinen [Fri, 5 Dec 2014 18:33:08 +0000 (20:33 +0200)] 
nl80211: Continue getting rid of NLA_PUT* macro use

This gets rid of more NLA_PUT* macro uses in nl80211 to reduce the
number of functions that depend on the hidden behavior of jumping to the
nla_put_failure label.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Get rid of NLA_PUT* macro use in capability checking
Jouni Malinen [Fri, 5 Dec 2014 17:24:38 +0000 (19:24 +0200)] 
nl80211: Get rid of NLA_PUT* macro use in capability checking

This gets rid of NLA_PUT* macro use in checking nl80211 capabilities to
reduce the number of functions that depend on the hidden behavior of
jumping to the nla_put_failure label.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoPCSC: Make AID copying easier for static analyzers
Jouni Malinen [Fri, 5 Dec 2014 21:18:56 +0000 (23:18 +0200)] 
PCSC: Make AID copying easier for static analyzers

Use a separate pointer and length field instead of trying to copy from a
struct field that has only part of the full buffer available.
(CID 68115)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoMake GTK length validation easier to analyze
Jouni Malinen [Fri, 5 Dec 2014 21:05:11 +0000 (23:05 +0200)] 
Make GTK length validation easier to analyze

Bounds checking for gd->gtk_len in wpa_supplicant_check_group_cipher()
was apparently too complex for some static analyzers. Use a local
variable and a more explicit validation step to avoid false report.
(CID 62864)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoFT: Make aes_wrap() call easier to analyze
Jouni Malinen [Fri, 5 Dec 2014 20:59:20 +0000 (22:59 +0200)] 
FT: Make aes_wrap() call easier to analyze

Using aes_wrap() to initialize a data structure seemed to be too much
for some static analyzers to understand. Make it obvious that the target
is not just the single struct member. (CID 68111)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoFT: Make aes_unwrap() calls easier to analyze
Jouni Malinen [Fri, 5 Dec 2014 20:52:06 +0000 (22:52 +0200)] 
FT: Make aes_unwrap() calls easier to analyze

Using aes_unwrap() to initialize a data structure seemed to be too much
for some static analyzers to understand. Make it obvious that the target
is initialized and that the target is not just the single struct member.
In addition, clean up the design to avoid removal of const with a
typecast. (CID 68112, CID 68134, CID 68135, CID 68136)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoP2P: Split p2p_channels_union() into two functions
Jouni Malinen [Fri, 5 Dec 2014 20:34:27 +0000 (22:34 +0200)] 
P2P: Split p2p_channels_union() into two functions

The separate p2p_channels_union_inplace() makes the function easier for
static analyzers to see that the result buffer is always initialized.
(CID 74494)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Optimize FT test cases
Jouni Malinen [Fri, 5 Dec 2014 15:12:30 +0000 (17:12 +0200)] 
tests: Optimize FT test cases

Use single channel scan instead of full scan to save time. In addition,
use EAP-GPSK which takes significantly less CPU that EAP-EKE with
default parameters.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: FT_DS with unknown target
Jouni Malinen [Fri, 5 Dec 2014 15:05:46 +0000 (17:05 +0200)] 
tests: FT_DS with unknown target

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: TDLS teardown using wildcard address
Jouni Malinen [Fri, 5 Dec 2014 14:56:14 +0000 (16:56 +0200)] 
tests: TDLS teardown using wildcard address

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: Disabling WNM keep-alive and hostapd doing client poll
Jouni Malinen [Fri, 5 Dec 2014 14:51:21 +0000 (16:51 +0200)] 
tests: Disabling WNM keep-alive and hostapd doing client poll

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: wpa_supplicant ctrl_iface SET operations
Jouni Malinen [Fri, 5 Dec 2014 14:24:21 +0000 (16:24 +0200)] 
tests: wpa_supplicant ctrl_iface SET operations

This adds more test coverage for wpa_supplicant SET ctrl_iface command.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: SET disallow_aps in P2P GO mode
Jouni Malinen [Fri, 5 Dec 2014 14:21:10 +0000 (16:21 +0200)] 
tests: SET disallow_aps in P2P GO mode

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: Optimize WFD connect_cli() calls
Jouni Malinen [Fri, 5 Dec 2014 13:30:46 +0000 (15:30 +0200)] 
tests: Optimize WFD connect_cli() calls

There is no need to run full scan in these test cases, so use single
channel scan to save time.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: WFD_SUBELEM_SET/GET with all parameter
Jouni Malinen [Fri, 5 Dec 2014 13:24:08 +0000 (15:24 +0200)] 
tests: WFD_SUBELEM_SET/GET with all parameter

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoWFD: Allow WFD_SUBELEM_SET/GET all to be used with full IE buffer
Jouni Malinen [Fri, 5 Dec 2014 13:22:33 +0000 (15:22 +0200)] 
WFD: Allow WFD_SUBELEM_SET/GET all to be used with full IE buffer

This extends the previously used WFD_SUBELEM_SET/GET <subelem id> design
to allow special "all" value to be used as an id to indicate that all
WFD subelements are to be set/get. This uses similar interface as was
previously added over D-Bus.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: More coverage for WMM-AC
Jouni Malinen [Fri, 5 Dec 2014 11:39:22 +0000 (13:39 +0200)] 
tests: More coverage for WMM-AC

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoWMM-AC: Use DEBUG verbosity for ignoring Action frame messages
Jouni Malinen [Fri, 5 Dec 2014 11:08:29 +0000 (13:08 +0200)] 
WMM-AC: Use DEBUG verbosity for ignoring Action frame messages

There is no point in flooding the log with WARNING or ERROR level
messages if WMM-AC related Action frames are ignored in cases where they
were not expected. In addition, WARNING/ERROR should not really be used
in cases an invalid frame is dropped especially if this is not related
to a security setup since external devices could otherwise generate log
entries.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agohostapd: Fix HT40 determination for ACS offload
Jouni Malinen [Thu, 4 Dec 2014 23:08:40 +0000 (01:08 +0200)] 
hostapd: Fix HT40 determination for ACS offload

Commit 16689c7cfc99c66aecbf16eb2f4a8bc941cb5d0f ('hostapd: Allow ACS to
be offloaded to the driver') used incorrect operator to determine
whether HT40 was configured. Fix that to mask the ht_capab bit
correctly. (CID 77286)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoHS 2.0: Clarify OSU Provider list length validation
Jouni Malinen [Thu, 4 Dec 2014 22:56:05 +0000 (00:56 +0200)] 
HS 2.0: Clarify OSU Provider list length validation

The previous version was somewhat too complex for some static analyzers.
Use local variables for the extracted length fields and explicitly
compare these against the remaining buffer length. (CID 68121)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Avoid a static analyzer warning on uninitialized emsk_len
Jouni Malinen [Thu, 4 Dec 2014 22:33:31 +0000 (00:33 +0200)] 
ERP: Avoid a static analyzer warning on uninitialized emsk_len

This was not really a real issue since bin_clear_free() would not use
the emsk_len argument when emsk is NULL as it would be on the path where
emsk_len has not been initilized. Anyway, it is better to get rid of the
warning.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoeap_example: Get rid of a compiler warning
Jouni Malinen [Thu, 4 Dec 2014 10:38:06 +0000 (12:38 +0200)] 
eap_example: Get rid of a compiler warning

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: EAP Re-authentication Protocol (ERP)
Jouni Malinen [Sat, 29 Nov 2014 18:34:43 +0000 (20:34 +0200)] 
tests: EAP Re-authentication Protocol (ERP)

This tests RP EAP-Initiate/Re-auth-Start transmission, ERP key
derivation, and EAP-Initiate/Re-auth + EAP-Finish/Re-auth exchange and
rMSK derivation.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Add wpa_supplicant ERP_FLUSH ctrl_iface command
Jouni Malinen [Sun, 30 Nov 2014 23:11:29 +0000 (01:11 +0200)] 
ERP: Add wpa_supplicant ERP_FLUSH ctrl_iface command

This can be used to flush all the ERP keys.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Add support for ERP on EAP peer
Jouni Malinen [Sat, 29 Nov 2014 21:14:40 +0000 (23:14 +0200)] 
ERP: Add support for ERP on EAP peer

Derive rRK and rIK on EAP peer if ERP is enabled. The new wpa_supplicant
network configuration parameter erp=1 can now be used to configure the
EAP peer to derive EMSK, rRK, and rIK at the successful completion of an
EAP authentication method. This functionality is not included in the
default build and can be enabled with CONFIG_ERP=y.

If EAP authenticator indicates support for re-authentication protocol,
initiate this with EAP-Initiate/Re-auth and complete protocol when
receiving EAP-Finish/Re-auth.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Add support for ERP on EAP server and authenticator
Jouni Malinen [Sat, 29 Nov 2014 19:28:24 +0000 (21:28 +0200)] 
ERP: Add support for ERP on EAP server and authenticator

Derive rRK and rIK on EAP server if ERP is enabled and use these keys to
allow EAP re-authentication to be used and to derive rMSK.

The new hostapd configuration parameter eap_server_erp=1 can now be used
to configure the integrated EAP server to derive EMSK, rRK, and rIK at
the successful completion of an EAP authentication method. This
functionality is not included in the default build and can be enabled
with CONFIG_ERP=y.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Add TV/TLV parser
Jouni Malinen [Sat, 29 Nov 2014 19:28:24 +0000 (21:28 +0200)] 
ERP: Add TV/TLV parser

This is needed for ERP implementation on both the server/authenticator
and peer side.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Add HMAC-SHA256 KDF (RFC 5295)
Jouni Malinen [Sat, 29 Nov 2014 19:28:24 +0000 (21:28 +0200)] 
ERP: Add HMAC-SHA256 KDF (RFC 5295)

This is needed for ERP key derivation.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Add optional EAP-Initiate/Re-auth-Start transmission
Jouni Malinen [Sat, 29 Nov 2014 18:33:09 +0000 (20:33 +0200)] 
ERP: Add optional EAP-Initiate/Re-auth-Start transmission

hostapd can now be configured to transmit EAP-Initiate/Re-auth-Start
before EAP-Request/Identity to try to initiate ERP. This is disabled by
default and can be enabled with erp_send_reauth_start=1 and optional
erp_reauth_start_domain=<domain>.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoERP: Add defines for EAP Re-Authentication Protocol
Jouni Malinen [Sat, 29 Nov 2014 18:32:28 +0000 (20:32 +0200)] 
ERP: Add defines for EAP Re-Authentication Protocol

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Ignore Connect failure for the previous association
Jithu Jance [Wed, 3 Dec 2014 13:24:40 +0000 (18:54 +0530)] 
nl80211: Ignore Connect failure for the previous association

Suppose there are two APs (AP1 & AP2) and user attempted to connect to
AP2 before the previous connection with AP1 could succeed. Now, if the
connection event comes for the older AP with failed status, we should
just ignore it as the wpa_supplicant state has moved to "ASSOCIATING"
with the new AP (AP2).

This is a similar to the case where a disconnection event is ignored for
a case where local disconnect request can cause the extra event to show
up during the next association process following that command.

Signed-off-by: Jithu Jance <jithu@broadcom.com>
10 years agohostapd: Allow ACS to be offloaded to the driver
Peng Xu [Tue, 18 Nov 2014 18:11:09 +0000 (20:11 +0200)] 
hostapd: Allow ACS to be offloaded to the driver

Using QCA vendor command, allow ACS function to be offloaded to the
driver. Once channels are selected, hostapd is notified to perform OBSS
operation.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoReturn only full network line in list_networks
Dmitry Shmidt [Wed, 3 Dec 2014 19:48:46 +0000 (11:48 -0800)] 
Return only full network line in list_networks

It makes more sense to truncate at line boundary especially with the new
LAST_ID parameter.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
10 years agotests: Huge number of network blocks and LIST_NETWORKS LAST_ID
Jouni Malinen [Tue, 2 Dec 2014 21:47:34 +0000 (23:47 +0200)] 
tests: Huge number of network blocks and LIST_NETWORKS LAST_ID

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoList all networks despite message limit of 4096 bytes
Vinit Deshpande [Tue, 2 Dec 2014 18:59:29 +0000 (10:59 -0800)] 
List all networks despite message limit of 4096 bytes

This change creates 'LIST_NETWORK LAST_ID=x' form to allow
retrieval of all networks saved in the system. Without this form,
only first few (whatever fills in first 4096 bytes) can be
retrieved.

Signed-off-by: Vinit Deshpande <vinitd@google.com>
10 years agoAdd a name for an assigned QCA nl80211 vendor subcmd
Jouni Malinen [Tue, 2 Dec 2014 21:36:12 +0000 (23:36 +0200)] 
Add a name for an assigned QCA nl80211 vendor subcmd

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoAllow a BSS entry with all-zeros BSSID to expire
Jouni Malinen [Tue, 2 Dec 2014 17:42:23 +0000 (19:42 +0200)] 
Allow a BSS entry with all-zeros BSSID to expire

wpa_bss_in_use() used to determine that a BSS with BSSID of
00:00:00:00:00:00 is in use in almost every case since either
wpa_s->bssid or wpa_s->pending_bssid was likely to be cleared. This
could result in a corner case of a BSS entry remaining in the BSS table
indefinitely if one was added there with a (likely bogus) address of
00:00:00:00:00:00. Fix this by ignore wpa_s->bssid and
wpa_s->pending_bssid if the BSSID in the BSS table entry is
00:00:00:00:00:00.

In theory, that address is a valid BSSID, but it is unlikely to be used
in any production AP, so the potential expiration of a BSS entry with
that address during a connection attempt would not be a concern
(especially when a new scan would be enough to recover from that).

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoRename QCA nl80211 vendor subcmds to match AOSP names
Jouni Malinen [Tue, 2 Dec 2014 14:19:25 +0000 (16:19 +0200)] 
Rename QCA nl80211 vendor subcmds to match AOSP names

This makes the enum vendor_subcmds definitions more consistent with the
names used in Android.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoatheros: Cleanup atheros_raw_receive to process all management frames
Vivek Natarajan [Mon, 1 Dec 2014 06:02:45 +0000 (11:32 +0530)] 
atheros: Cleanup atheros_raw_receive to process all management frames

Signed-off-by: Vivek Natarajan <nataraja@qti.qualcomm.com>
10 years agotests: Make scan_for_auth more robust
Jouni Malinen [Mon, 1 Dec 2014 15:50:58 +0000 (17:50 +0200)] 
tests: Make scan_for_auth more robust

It was apparently possible for this test case not to do what it was
supposed to do, i.e., get nl80211 Authenticate command failing due to
cfg80211 BS entry missing. With the external radio work blocking fixed,
this can be cleaned up by explicitly waiting for the scan event. In
addition, a less used channel can be selected to avoid finding other BSS
entries.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoDo not start new radio work on scan completion during ext work
Jouni Malinen [Mon, 1 Dec 2014 15:49:19 +0000 (17:49 +0200)] 
Do not start new radio work on scan completion during ext work

Externally triggered scan could result in a new radio work item getting
started even when external radio work was in progress. Delay such start
until the external work is completed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: Add a helper function for clearing scan cache
Jouni Malinen [Mon, 1 Dec 2014 10:14:11 +0000 (12:14 +0200)] 
tests: Add a helper function for clearing scan cache

This makes it more convenient and consistent to clear the cached scan
results from cfg80211 and wpa_supplicant.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoEAP-PAX: Derive EAP Session-Id
Jouni Malinen [Sun, 30 Nov 2014 23:45:17 +0000 (01:45 +0200)] 
EAP-PAX: Derive EAP Session-Id

This adds EAP-PAX server and peer method functions for deriving
Session-Id from Method-Id per RFC 4746 and RFC 5247.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoEAP-TTLS: Add support for deriving EMSK
Jouni Malinen [Sun, 30 Nov 2014 23:27:01 +0000 (01:27 +0200)] 
EAP-TTLS: Add support for deriving EMSK

This extends EAP-TTLS server and peer implementations to support EMSK
derivation per RFC 5281.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoEAP-TLS server: Clear temporary buffer during EMSK derivation
Jouni Malinen [Sun, 30 Nov 2014 23:25:52 +0000 (01:25 +0200)] 
EAP-TLS server: Clear temporary buffer during EMSK derivation

Now that EMSK derivation is taken into use with ERP, it is better to
make sure the temporary MSK + EMSK buffer does not get left in heap
after use.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoEAP server: Add getSessionId
Jouni Malinen [Sat, 29 Nov 2014 21:46:45 +0000 (23:46 +0200)] 
EAP server: Add getSessionId

This extends EAP server implementation to derive Session-Id similarly to
the existing EAP peer implementation.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoEAP peer: Clean up TLS Session-Id derivation function
Jouni Malinen [Sat, 29 Nov 2014 22:22:10 +0000 (00:22 +0200)] 
EAP peer: Clean up TLS Session-Id derivation function

The comment about library not supporting Session-Id derivation was not
accurate and there is no need to check for master key that is not used
as part of derivation.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: AddressSanitizer (ASan) build options
Jouni Malinen [Sun, 30 Nov 2014 13:52:28 +0000 (15:52 +0200)] 
tests: AddressSanitizer (ASan) build options

Add example build options that can be used to enable ASan for hwsim test
cases.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoWPS: Fix current_ssid clearing on duplicate network removal
Jouni Malinen [Sun, 30 Nov 2014 13:48:37 +0000 (15:48 +0200)] 
WPS: Fix current_ssid clearing on duplicate network removal

It was possible for the current network profile to be deleted when
merging duplicated WPS credentials. However, this did not clear
wpa_s->current_ssid and it was possible for something else to end up
dereferencing that pointer to now freed memory. This could be hit, e.g.,
with ap_wps_mixed_cred. Fix this by clearing current_ssid also in this
code path similarly to other cases of network block getting removed.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agomesh: Skip fast-association when using connect_without_scan
Jouni Malinen [Sun, 30 Nov 2014 13:47:07 +0000 (15:47 +0200)] 
mesh: Skip fast-association when using connect_without_scan

The mesh group addition was designed to use wpa_s->connect_without_scan
to skip a scan. That path was skipped if wpa_supplicant_fast_associate()
allowed previous scan results to be used. This could result in undesired
double-initialization attempt for the mesh interface. Avoid this by not
using wpa_supplicant_fast_associate() when wpa_s->connect_without_scan
is set.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agomesh: Check for initialization failures
Jouni Malinen [Sun, 30 Nov 2014 13:46:09 +0000 (15:46 +0200)] 
mesh: Check for initialization failures

It is possible that these location ended up getting called before mesh
startup operations had been completed and that could result in
dereferencing NULL pointers. Address those error cases by verifying that
the needed parameters are available before using them.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Stop connection at the end of monitor_iface_unknown_sta
Jouni Malinen [Sun, 30 Nov 2014 13:44:37 +0000 (15:44 +0200)] 
tests: Stop connection at the end of monitor_iface_unknown_sta

Do not leave the station trying to connect at the end of the test case
since that can have an effect to the following test case. Such sequences
should be tested in test cases that are specifically designed for that
rather than randomly between test cases.

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