[PATCH v2 08/12] P2PS: Fix persist reporting in wpas_p2ps_prov_complete()

Ilan Peer ilan.peer
Thu Oct 8 02:36:03 PDT 2015


From: Max Stepanov <Max.Stepanov at intel.com>

When one peer doesn't include a persistent group info in PD request
the other peer shouldn't report a persistent group usage with this
peer even if such a persistent group exists locally. This condition
can be violated in the current implementation.

In the case when a local persistent group exists and
wpas_p2ps_prov_complete() function is called with persist_ssid
parameter set to NULL, the supplicant reports P2PS-PROV-DONE
with persist=<idx> instead of conncap=<role> parameter.

It happens because wpas_p2p_get_persistent() function is called without
verification if the persist_ssid is set to NULL or or not. In this
case the wpas_p2p_get_persisten() returns the first existing persistent
group matching the device address without verifying the group's SSID.
After that the group ID is used as persist=<idx> parameter of
P2PS-PROV-DONE event.

Fix the issue by adding persist_ssid and persist_ssid_size
verification before wpas_p2p_get_persistent() call.

Signed-off-by: Max Stepanov <Max.Stepanov at intel.com>
---
 wpa_supplicant/p2p_supplicant.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 2ed1bf2..bce3dfe 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -3814,7 +3814,7 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
 {
 	struct wpa_supplicant *wpa_s = ctx;
 	u8 mac[ETH_ALEN];
-	struct wpa_ssid *persistent_go, *stale, *s;
+	struct wpa_ssid *persistent_go, *stale, *s = NULL;
 	int save_config = 0;
 	struct wpa_supplicant *go_wpa_s;
 	char feat_cap_str[256];
@@ -3885,8 +3885,9 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev,
 	}
 
 	/* Clean up stale persistent groups with this device */
-	s = wpas_p2p_get_persistent(wpa_s, dev, persist_ssid,
-				    persist_ssid_size);
+	if (persist_ssid && persist_ssid_size)
+		s = wpas_p2p_get_persistent(wpa_s, dev, persist_ssid,
+					    persist_ssid_size);
 
 	if (persist_ssid && s && s->mode != WPAS_MODE_P2P_GO &&
 	    is_zero_ether_addr(grp_mac)) {
-- 
1.9.1




More information about the Hostap mailing list