diff mbox series

Subject: [PATCH 1/1] STA_ASSOC: Mark Port authorization and State Completion based on authorized state in connect event

Message ID CAMLe8U9-Yi-YUqNRGnNgvs-uzMS9cwX6=g-m+4zkpZUwxZ4Z0g@mail.gmail.com
State Superseded
Headers show
Series Subject: [PATCH 1/1] STA_ASSOC: Mark Port authorization and State Completion based on authorized state in connect event | expand

Commit Message

Vinayak Yadawad June 20, 2022, 5:56 a.m. UTC
In case of drivers supporting 4way handshake offload, mark port
authorized and state completion only if driver advertizes authorized
state in the connect event. Otherwise there are fair chances of driver
port authorization api gets called while 4-way handshake is in progress
at the lower layer.
In order to avoid this possible race condition always update port
authorization and supplicant state WPA_COMPLETED setting from
EVENT_PORT_AUTHORIZED context when driver is done with 4way handshake.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
---
 wpa_supplicant/events.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

  /*

Comments

Vinayak Yadawad June 20, 2022, 6:48 a.m. UTC | #1
PFA  patch for reference generated using the git repo

On Mon, Jun 20, 2022 at 11:26 AM Vinayak Yadawad
<vinayak.yadawad@broadcom.com> wrote:
>
> In case of drivers supporting 4way handshake offload, mark port
> authorized and state completion only if driver advertizes authorized
> state in the connect event. Otherwise there are fair chances of driver
> port authorization api gets called while 4-way handshake is in progress
> at the lower layer.
> In order to avoid this possible race condition always update port
> authorization and supplicant state WPA_COMPLETED setting from
> EVENT_PORT_AUTHORIZED context when driver is done with 4way handshake.
>
> Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
> ---
>  wpa_supplicant/events.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> index ec56cfdc0..f20e1c87b 100644
> --- a/wpa_supplicant/events.c
> +++ b/wpa_supplicant/events.c
> @@ -3478,14 +3478,23 @@ static void wpa_supplicant_event_assoc(struct
> wpa_supplicant *wpa_s,
>   eapol_sm_notify_eap_success(wpa_s->eapol, true);
>   } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_PSK) &&
>      wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
> - /*
> - * We are done; the driver will take care of RSN 4-way
> - * handshake.
> - */
> - wpa_supplicant_cancel_auth_timeout(wpa_s);
> - wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
> - eapol_sm_notify_portValid(wpa_s->eapol, true);
> - eapol_sm_notify_eap_success(wpa_s->eapol, true);
> + if (already_authorized) {
> + /*
> + * We are done; the driver will take care of RSN 4-way
> + * handshake.
> + */
> + wpa_supplicant_cancel_auth_timeout(wpa_s);
> + wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
> + eapol_sm_notify_portValid(wpa_s->eapol, true);
> + eapol_sm_notify_eap_success(wpa_s->eapol, true);
> + } else {
> + /* Update port, WPA_COMPLETED state from
> + * EVENT_PORT_AUTHORIZED context when driver is done
> + * with 4way handshake.
> + */
> + wpa_msg(wpa_s, MSG_INFO, "ASSOC INFO: wait for driver port "
> + "authorized indication");
> + }
>   } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X) &&
>      wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
>   /*
> --
> 2.32.0
Vinayak Yadawad June 21, 2022, 8:39 a.m. UTC | #2
Kindly ignore this patch request, as it has errors with indentation.
I will be sending a fresh email  request for the patch submission.

On Mon, Jun 20, 2022 at 12:18 PM Vinayak Yadawad
<vinayak.yadawad@broadcom.com> wrote:
>
> PFA  patch for reference generated using the git repo
>
> On Mon, Jun 20, 2022 at 11:26 AM Vinayak Yadawad
> <vinayak.yadawad@broadcom.com> wrote:
> >
> > In case of drivers supporting 4way handshake offload, mark port
> > authorized and state completion only if driver advertizes authorized
> > state in the connect event. Otherwise there are fair chances of driver
> > port authorization api gets called while 4-way handshake is in progress
> > at the lower layer.
> > In order to avoid this possible race condition always update port
> > authorization and supplicant state WPA_COMPLETED setting from
> > EVENT_PORT_AUTHORIZED context when driver is done with 4way handshake.
> >
> > Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
> > ---
> >  wpa_supplicant/events.c | 25 +++++++++++++++++--------
> >  1 file changed, 17 insertions(+), 8 deletions(-)
> >
> > diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> > index ec56cfdc0..f20e1c87b 100644
> > --- a/wpa_supplicant/events.c
> > +++ b/wpa_supplicant/events.c
> > @@ -3478,14 +3478,23 @@ static void wpa_supplicant_event_assoc(struct
> > wpa_supplicant *wpa_s,
> >   eapol_sm_notify_eap_success(wpa_s->eapol, true);
> >   } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_PSK) &&
> >      wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
> > - /*
> > - * We are done; the driver will take care of RSN 4-way
> > - * handshake.
> > - */
> > - wpa_supplicant_cancel_auth_timeout(wpa_s);
> > - wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
> > - eapol_sm_notify_portValid(wpa_s->eapol, true);
> > - eapol_sm_notify_eap_success(wpa_s->eapol, true);
> > + if (already_authorized) {
> > + /*
> > + * We are done; the driver will take care of RSN 4-way
> > + * handshake.
> > + */
> > + wpa_supplicant_cancel_auth_timeout(wpa_s);
> > + wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
> > + eapol_sm_notify_portValid(wpa_s->eapol, true);
> > + eapol_sm_notify_eap_success(wpa_s->eapol, true);
> > + } else {
> > + /* Update port, WPA_COMPLETED state from
> > + * EVENT_PORT_AUTHORIZED context when driver is done
> > + * with 4way handshake.
> > + */
> > + wpa_msg(wpa_s, MSG_INFO, "ASSOC INFO: wait for driver port "
> > + "authorized indication");
> > + }
> >   } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X) &&
> >      wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
> >   /*
> > --
> > 2.32.0
diff mbox series

Patch

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index ec56cfdc0..f20e1c87b 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3478,14 +3478,23 @@  static void wpa_supplicant_event_assoc(struct
wpa_supplicant *wpa_s,
  eapol_sm_notify_eap_success(wpa_s->eapol, true);
  } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_PSK) &&
     wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
- /*
- * We are done; the driver will take care of RSN 4-way
- * handshake.
- */
- wpa_supplicant_cancel_auth_timeout(wpa_s);
- wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
- eapol_sm_notify_portValid(wpa_s->eapol, true);
- eapol_sm_notify_eap_success(wpa_s->eapol, true);
+ if (already_authorized) {
+ /*
+ * We are done; the driver will take care of RSN 4-way
+ * handshake.
+ */
+ wpa_supplicant_cancel_auth_timeout(wpa_s);
+ wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
+ eapol_sm_notify_portValid(wpa_s->eapol, true);
+ eapol_sm_notify_eap_success(wpa_s->eapol, true);
+ } else {
+ /* Update port, WPA_COMPLETED state from
+ * EVENT_PORT_AUTHORIZED context when driver is done
+ * with 4way handshake.
+ */
+ wpa_msg(wpa_s, MSG_INFO, "ASSOC INFO: wait for driver port "
+ "authorized indication");
+ }
  } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X) &&
     wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {