All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Kees Cook <keescook@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Fabio Aiuto <fabioaiuto83@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-staging@lists.linux.dev,
	Michael Straube <straube.linux@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: Allocate full pwep structure
Date: Mon, 20 Jun 2022 12:55:00 +0300	[thread overview]
Message-ID: <20220620095500.GI16517@kadam> (raw)
In-Reply-To: <38d31460-f3e0-1260-05c5-406a05d9fb37@wanadoo.fr>

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


      reply	other threads:[~2022-06-20  9:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 21:55 [PATCH] staging: rtl8723bs: Allocate full pwep structure Kees Cook
2022-06-18  7:51 ` Christophe JAILLET
2022-06-20  9:55   ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220620095500.GI16517@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=arnd@arndb.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=fabioaiuto83@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=straube.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.