lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 20 Jun 2022 12:55:00 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Kees Cook <keescook@...omium.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Fabio Aiuto <fabioaiuto83@...il.com>,
        Hans de Goede <hdegoede@...hat.com>,
        linux-staging@...ts.linux.dev,
        Michael Straube <straube.linux@...il.com>,
        Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: Allocate full pwep structure

On Sat, Jun 18, 2022 at 09:51:36AM +0200, Christophe JAILLET wrote:
> > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> > index ece97e37ac91..30374a820496 100644
> > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> > @@ -90,7 +90,8 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
> >   		if (wep_key_len > 0) {
> >   			wep_key_len = wep_key_len <= 5 ? 5 : 13;
> >   			wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, key_material);
> > -			pwep = kzalloc(wep_total_len, GFP_KERNEL);
> > +			/* Allocate a full structure to avoid potentially running off the end. */
> > +			pwep = kzalloc(sizeof(*pwep), GFP_KERNEL);
> >   			if (!pwep) {
> >   				ret = -ENOMEM;
> >   				goto exit;
> > @@ -582,7 +583,8 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
> >   		if (wep_key_len > 0) {
> >   			wep_key_len = wep_key_len <= 5 ? 5 : 13;
> >   			wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, key_material);
> > -			pwep = kzalloc(wep_total_len, GFP_KERNEL);
> > +			/* Allocate a full structure to avoid potentially running off the end. */
> > +			pwep = kzalloc(sizeof(*pwep), GFP_KERNEL);
> >   			if (!pwep)
> 
> Hi,
> 
> while at it (and un-related tyo your patch), I think that 'ret' should also
> be updated here, otherwise we return 0.
> 

Too late.  Smatch does catch that bug btw.

drivers/staging/r8188eu/os_dep/ioctl_linux.c:409 wpa_set_encryption() warn: missing error code here? 'kzalloc()' failed. 'ret' = '0'

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ