[PATCH] P2P: Prevent p2p connect misuse

Jouni Malinen j at w1.fi
Sun Mar 1 04:57:23 EST 2015


On Sat, Dec 06, 2014 at 12:49:06PM +0100, Arend van Spriel wrote:
> Would it be better to call the p2p_ctrl_*() functions with
> wpa_s->global->p2p_init_wpa_s. At least p2p_ctrl_find() and probably
> p2p_ctrl_connect(). Or should it be decided at another level in the
> supplicant.

It is more complex than that since some of the commands may actually
apply to the group interface rather than the global management
interface. Something like this is likely needed to be done for some of
the commands:

P2P: Direct P2P_CONNECT command to proper interface

It is possible for the P2P_CONNECT control interface command to be
issued on an incorrect interface. While the upper layer component should
really use global control interface for this, make this work by
redirecting the command to the correct context if needed.

Signed-off-by: Jouni Malinen <j at w1.fi>
---
 wpa_supplicant/ctrl_iface.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index a2d79fa..e840b35 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -4741,6 +4741,14 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
 	int pd;
 	int ht40, vht;
 
+	if (!wpa_s->global->p2p_init_wpa_s)
+		return -1;
+	if (wpa_s->global->p2p_init_wpa_s != wpa_s) {
+		wpa_dbg(wpa_s, MSG_DEBUG, "Direct P2P_CONNECT command to %s",
+			wpa_s->global->p2p_init_wpa_s->ifname);
+		wpa_s = wpa_s->global->p2p_init_wpa_s;
+	}
+
 	/* <addr> <"pbc" | "pin" | PIN> [label|display|keypad|p2ps]
 	 * [persistent|persistent=<network id>]
 	 * [join] [auth] [go_intent=<0..15>] [freq=<in MHz>] [provdisc]
-- 
1.9.1


-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list