[PATCH v2] P2P: prevent p2pdev from roaming

Jouni Malinen j
Sun Mar 1 01:35:06 PST 2015


On Mon, Dec 01, 2014 at 10:54:11AM +0100, Michal Kazior wrote:
> It was possible for a P2P_DEVICE to receive scan results and
> subsequently start roaming due to a matching network. This caused
> P2P find stop working (state machines seemed to be confused).

> Since p2p-dev-* isn't even a netdev make sure to prevent roaming
> for it and prevent subsequent state machine confusion.

> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> @@ -1146,6 +1146,8 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
> +	if (wpa_s->p2p_mgmt)
> +		return 0; /* p2pdev isn't even a netdev so it can't roam */
>  	if (wpa_s->reassociate)
>  		return 1; /* explicit request to reassociate */

This looks like a good direction, but the specific change here is not
generic enough to skip all the needed cases. As an example, there would
not be any point in starting a scan or selecting the network from
results. I'm thinking of applying something like this to cover most of
these cases:

P2P: Do not allow scan or normal association on cfg80211 P2P Device

The dedicated P2P management instance (wpas->p2p_mgmt == 1) using
cfg80211 P2P Device cannot be used for non-P2P uses or connection (there
is no netdev). Reject or ignore such operations to avoid unexpected
operations if enabled network blocks are configured in the
wpa_supplicant instance used to control this interface.

Signed-off-by: Jouni Malinen <j at w1.fi>
---
 wpa_supplicant/events.c         |  3 +++
 wpa_supplicant/scan.c           | 17 +++++++++++++++--
 wpa_supplicant/wpa_supplicant.c |  3 +++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index f76fe97..1f9fc97 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -1421,6 +1421,9 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
 	struct wpa_bss *selected;
 	struct wpa_ssid *ssid = NULL;
 
+	if (wpa_s->p2p_mgmt)
+		return 0; /* no normal connection on p2p_mgmt interface */
+
 	selected = wpa_supplicant_pick_network(wpa_s, &ssid);
 
 	if (selected) {
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 6e376a2..27e2cc0 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -96,6 +96,10 @@ int wpa_supplicant_enabled_networks(struct wpa_supplicant *wpa_s)
 {
 	struct wpa_ssid *ssid = wpa_s->conf->ssid;
 	int count = 0, disabled = 0;
+
+	if (wpa_s->p2p_mgmt)
+		return 0; /* no normal network profiles on p2p_mgmt interface */
+
 	while (ssid) {
 		if (!wpas_network_disabled(wpa_s, ssid))
 			count++;
@@ -1066,8 +1070,17 @@ void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec)
  */
 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec)
 {
-	int res = eloop_deplete_timeout(sec, usec, wpa_supplicant_scan, wpa_s,
-					NULL);
+	int res;
+
+	if (wpa_s->p2p_mgmt) {
+		wpa_dbg(wpa_s, MSG_DEBUG,
+			"Ignore scan request (%d.%06d sec) on p2p_mgmt interface",
+			sec, usec);
+		return;
+	}
+
+	res = eloop_deplete_timeout(sec, usec, wpa_supplicant_scan, wpa_s,
+				    NULL);
 	if (res == 1) {
 		wpa_dbg(wpa_s, MSG_DEBUG, "Rescheduling scan request: %d.%06d sec",
 			sec, usec);
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 16f05c7..e96199e 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -4966,6 +4966,9 @@ int wpas_network_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
 	int i;
 	unsigned int drv_enc;
 
+	if (wpa_s->p2p_mgmt)
+		return 1; /* no normal network profiles on p2p_mgmt interface */
+
 	if (ssid == NULL)
 		return 1;
 
-- 
1.9.1

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list