nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lyude Paul <lyude@redhat.com>
To: Greg KH <gregkh@linuxfoundation.org>, Zhou Qingyang <zhou1615@umn.edu>
Cc: David Airlie <airlied@linux.ie>,
	nouveau@lists.freedesktop.org, kjlu@umn.edu,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Ben Skeggs <bskeggs@redhat.com>, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [Nouveau] [PATCH] drm/nouveau/acr: Fix undefined behavior in nvkm_acr_hsfw_load_bl()
Date: Fri, 28 Jan 2022 14:20:24 -0500	[thread overview]
Message-ID: <536c833413ccbe0b8ad653a50c5ea867bf975290.camel@redhat.com> (raw)
In-Reply-To: <YfPC3N+H9Fu/gqpz@kroah.com>

Sigh-thank you for catching this - I had totally forgot about the umn.edu ban.
I pushed this already but I will go ahead and send a revert for this patch.
Will cc you on it as well.

On Fri, 2022-01-28 at 11:18 +0100, Greg KH wrote:
> On Tue, Jan 25, 2022 at 12:58:55AM +0800, Zhou Qingyang wrote:
> > In nvkm_acr_hsfw_load_bl(), the return value of kmalloc() is directly
> > passed to memcpy(), which could lead to undefined behavior on failure
> > of kmalloc().
> > 
> > Fix this bug by using kmemdup() instead of kmalloc()+memcpy().
> > 
> > This bug was found by a static analyzer.
> > 
> > Builds with 'make allyesconfig' show no new warnings,
> > and our static analyzer no longer warns about this code.
> > 
> > Fixes: 22dcda45a3d1 ("drm/nouveau/acr: implement new subdev to replace
> > "secure boot"")
> > Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
> > ---
> > The analysis employs differential checking to identify inconsistent 
> > security operations (e.g., checks or kfrees) between two code paths 
> > and confirms that the inconsistent operations are not recovered in the
> > current function or the callers, so they constitute bugs. 
> > 
> > Note that, as a bug found by static analysis, it can be a false
> > positive or hard to trigger. Multiple researchers have cross-reviewed
> > the bug.
> > 
> >  drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c
> > b/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c
> > index 667fa016496e..a6ea89a5d51a 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c
> > @@ -142,11 +142,12 @@ nvkm_acr_hsfw_load_bl(struct nvkm_acr *acr, const
> > char *name, int ver,
> >  
> >         hsfw->imem_size = desc->code_size;
> >         hsfw->imem_tag = desc->start_tag;
> > -       hsfw->imem = kmalloc(desc->code_size, GFP_KERNEL);
> > -       memcpy(hsfw->imem, data + desc->code_off, desc->code_size);
> > -
> > +       hsfw->imem = kmemdup(data + desc->code_off, desc->code_size,
> > GFP_KERNEL);
> >         nvkm_firmware_put(fw);
> > -       return 0;
> > +       if (!hsfw->imem)
> > +               return -ENOMEM;
> > +       else
> > +               return 0;
> >  }
> >  
> >  int
> > -- 
> > 2.25.1
> > 
> 
> As stated before, umn.edu is still not allowed to contribute to the
> Linux kernel.  Please work with your administration to resolve this
> issue.
> 

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat


  reply	other threads:[~2022-01-28 19:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 16:58 [Nouveau] [PATCH] drm/nouveau/acr: Fix undefined behavior in nvkm_acr_hsfw_load_bl() Zhou Qingyang
2022-01-25 19:11 ` Lyude Paul
2022-01-28 10:18 ` Greg KH
2022-01-28 19:20   ` Lyude Paul [this message]
2022-01-28 19:53     ` Alex Deucher
2022-01-28 19:57       ` Lyude Paul
2022-01-29  8:32         ` Greg KH
2022-01-28 19:57       ` Karol Herbst
2022-01-28 20:01         ` Alex Deucher
2022-01-29  8:30         ` Greg KH
2022-01-29 14:18         ` Kangjie Lu
2022-01-29 14:47           ` Greg KH
2022-01-29 15:19             ` Kangjie Lu
2022-01-29 15:54               ` Greg KH
2022-01-29  8:24     ` Greg KH

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=536c833413ccbe0b8ad653a50c5ea867bf975290.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=airlied@linux.ie \
    --cc=bskeggs@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=zhou1615@umn.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).