Re: [PATCH 09/10] Switch from using os_random() to using os_get_random(...) in wpas_auth_failed(...)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Feb 14, 2016 at 07:41:19PM +0000, Nick Lowe wrote:
>  Switch from using os_random() to using
>  os_get_random(...) in wpas_auth_failed(...) The intention is to facilitate
>  the future removal of os_random(). os_random() uses a low quality PRNG which
>  we should avoid using outright unless there is a compelling performance
>  justification to do so.

> diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
>  void wpas_auth_failed(struct wpa_supplicant *wpa_s, char *reason)

> -    int dur;
> +    int dur, r;

> -        wpa_key_mgmt_wpa_ieee8021x(ssid->key_mgmt))
> -        dur += os_random() % (ssid->auth_failures * 10);
> +            wpa_key_mgmt_wpa_ieee8021x(ssid->key_mgmt) &&
> +            os_get_random((u8 *) &r, sizeof(r)) >= 0)
> +        dur += r % (ssid->auth_failures * 10);

This does not look safe. Shouldn't r be unsigned at minimum? The
proposed construction seems to have about 0.5 chance of being negative
and reducing the wait duration. Please note that os_random() returns
unsigned long. The dur variable could also be changed to be unsigned
(not that this construction would be able to go beyond the maximum int
value in practice).
 
-- 
Jouni Malinen                                            PGP id EFC895FA

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux