3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

Register EAPOL frame listeners earlier

If we register the main EAPOL frame listener as late as the associate
event, it may not observe ptk_1_of_4. This defeats handling for early
messages in eapol_rx_packet, which only sees messages once it has been
registered.

If we move registration to the authenticate event, then the EAPOL
frame listeners should observe all messages, without any possible
races. Note that the messages are not actually processed until
eapol_start() is called, and we haven't moved that call site. All
that's changing here is how early EAPOL messages can be observed.
This commit is contained in:
Ed Smith 2024-03-28 16:39:31 -06:00 committed by Denis Kenzior
parent ccd702f7da
commit da13aab419

View File

@ -2896,6 +2896,15 @@ static bool kernel_will_retry_auth(uint16_t status_code,
return false;
}
static void netdev_ensure_eapol_registered(struct netdev *netdev)
{
if (L_WARN_ON(netdev->sm))
return;
netdev->sm = eapol_sm_new(netdev->handshake);
eapol_register(netdev->sm);
}
static void netdev_authenticate_event(struct l_genl_msg *msg,
struct netdev *netdev)
{
@ -2982,7 +2991,12 @@ static void netdev_authenticate_event(struct l_genl_msg *msg,
NULL, netdev->user_data);
/* We have sent another CMD_AUTHENTICATE / CMD_ASSOCIATE */
if (ret == 0 || ret == -EAGAIN)
if (ret == 0) {
netdev_ensure_eapol_registered(netdev);
return;
}
if (ret == -EAGAIN)
return;
retry = kernel_will_retry_auth(status_code,
@ -3099,9 +3113,6 @@ static void netdev_associate_event(struct l_genl_msg *msg,
netdev->ap = NULL;
}
netdev->sm = eapol_sm_new(netdev->handshake);
eapol_register(netdev->sm);
/* Just in case this was a retry */
netdev->ignore_connect_event = false;
@ -4292,6 +4303,8 @@ int netdev_ft_reassociate(struct netdev *netdev,
if (netdev->sm) {
eapol_sm_free(netdev->sm);
netdev->sm = NULL;
netdev_ensure_eapol_registered(netdev);
}
msg = netdev_build_cmd_associate_common(netdev);