linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nv50_disp_chan_mthd: ensure mthd is not NULL
@ 2020-02-08 19:43 Frédéric Pierret
  2020-02-20 17:19 ` Frédéric Pierret
  0 siblings, 1 reply; 4+ messages in thread
From: Frédéric Pierret @ 2020-02-08 19:43 UTC (permalink / raw)
  To: bskeggs, airlied, daniel, dri-devel, nouveau, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1271 bytes --]

Pointer to structure array is assumed not NULL by default. It has
the consequence to raise a kernel panic when it's not the case.

Basically, running at least a RTX2080TI on Xen makes a bad mmio error
which causes having 'mthd' pointer to be NULL in 'channv50.c'. From the
code, it's assumed to be not NULL by accessing directly 'mthd->data[0]'
which is the reason of the kernel panic. Simply check if the pointer
is not NULL before continuing.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206299
Cc: stable@vger.kernel.org
Signed-off-by: Frédéric Pierret (fepitre) <frederic.pierret@qubes-os.org>
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
index bcf32d92ee5a..50e3539f33d2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
@@ -74,6 +74,8 @@ nv50_disp_chan_mthd(struct nv50_disp_chan *chan, int debug)
 
 	if (debug > subdev->debug)
 		return;
+	if (!mthd)
+		return;
 
 	for (i = 0; (list = mthd->data[i].mthd) != NULL; i++) {
 		u32 base = chan->head * mthd->addr;
-- 
2.21.0



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nv50_disp_chan_mthd: ensure mthd is not NULL
  2020-02-08 19:43 [PATCH] nv50_disp_chan_mthd: ensure mthd is not NULL Frédéric Pierret
@ 2020-02-20 17:19 ` Frédéric Pierret
  2020-02-20 17:32   ` [Nouveau] " Ilia Mirkin
  0 siblings, 1 reply; 4+ messages in thread
From: Frédéric Pierret @ 2020-02-20 17:19 UTC (permalink / raw)
  To: bskeggs, airlied, daniel, dri-devel, nouveau, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1464 bytes --]

Hi,
Is anything missing here? How can I get this merged?

Best regards,
Frédéric Pierret

On 2020-02-08 20:43, Frédéric Pierret wrote:
> Pointer to structure array is assumed not NULL by default. It has
> the consequence to raise a kernel panic when it's not the case.
> 
> Basically, running at least a RTX2080TI on Xen makes a bad mmio error
> which causes having 'mthd' pointer to be NULL in 'channv50.c'. From the
> code, it's assumed to be not NULL by accessing directly 'mthd->data[0]'
> which is the reason of the kernel panic. Simply check if the pointer
> is not NULL before continuing.
> 
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206299
> Cc: stable@vger.kernel.org
> Signed-off-by: Frédéric Pierret (fepitre) <frederic.pierret@qubes-os.org>
> ---
>  drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
> index bcf32d92ee5a..50e3539f33d2 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
> @@ -74,6 +74,8 @@ nv50_disp_chan_mthd(struct nv50_disp_chan *chan, int debug)
>  
>  	if (debug > subdev->debug)
>  		return;
> +	if (!mthd)
> +		return;
>  
>  	for (i = 0; (list = mthd->data[i].mthd) != NULL; i++) {
>  		u32 base = chan->head * mthd->addr;
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Nouveau] [PATCH] nv50_disp_chan_mthd: ensure mthd is not NULL
  2020-02-20 17:19 ` Frédéric Pierret
@ 2020-02-20 17:32   ` Ilia Mirkin
  2020-02-20 18:09     ` Frédéric Pierret
  0 siblings, 1 reply; 4+ messages in thread
From: Ilia Mirkin @ 2020-02-20 17:32 UTC (permalink / raw)
  To: Frédéric Pierret
  Cc: Ben Skeggs, David Airlie, Daniel Vetter, dri-devel, nouveau, LKML

Hi Frédéric,

It appears Ben made his own version of this patch (probably based on
the one you added to the kernel bz), and it's already upstream:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.6-rc2&id=0e6176c6d286316e9431b4f695940cfac4ffe6c2

Cheers,

  -ilia

On Thu, Feb 20, 2020 at 12:19 PM Frédéric Pierret
<frederic.pierret@qubes-os.org> wrote:
>
> Hi,
> Is anything missing here? How can I get this merged?
>
> Best regards,
> Frédéric Pierret
>
> On 2020-02-08 20:43, Frédéric Pierret wrote:
> > Pointer to structure array is assumed not NULL by default. It has
> > the consequence to raise a kernel panic when it's not the case.
> >
> > Basically, running at least a RTX2080TI on Xen makes a bad mmio error
> > which causes having 'mthd' pointer to be NULL in 'channv50.c'. From the
> > code, it's assumed to be not NULL by accessing directly 'mthd->data[0]'
> > which is the reason of the kernel panic. Simply check if the pointer
> > is not NULL before continuing.
> >
> > BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206299
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Frédéric Pierret (fepitre) <frederic.pierret@qubes-os.org>
> > ---
> >  drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
> > index bcf32d92ee5a..50e3539f33d2 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
> > @@ -74,6 +74,8 @@ nv50_disp_chan_mthd(struct nv50_disp_chan *chan, int debug)
> >
> >       if (debug > subdev->debug)
> >               return;
> > +     if (!mthd)
> > +             return;
> >
> >       for (i = 0; (list = mthd->data[i].mthd) != NULL; i++) {
> >               u32 base = chan->head * mthd->addr;
> >
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Nouveau] [PATCH] nv50_disp_chan_mthd: ensure mthd is not NULL
  2020-02-20 17:32   ` [Nouveau] " Ilia Mirkin
@ 2020-02-20 18:09     ` Frédéric Pierret
  0 siblings, 0 replies; 4+ messages in thread
From: Frédéric Pierret @ 2020-02-20 18:09 UTC (permalink / raw)
  To: Ilia Mirkin
  Cc: Ben Skeggs, David Airlie, Daniel Vetter, dri-devel, nouveau, LKML


[-- Attachment #1.1: Type: text/plain, Size: 2495 bytes --]

Hi Ilia,
Well...if Ben made it's own version you mean using my patch given on comment https://bugzilla.kernel.org/show_bug.cgi?id=206299#c9 and then adding commit message without quoting me as reporter ok...

At least, upstream is patched.

Best,
Frédéric

On 2020-02-20 18:32, Ilia Mirkin wrote:
> Hi Frédéric,
> 
> It appears Ben made his own version of this patch (probably based on
> the one you added to the kernel bz), and it's already upstream:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.6-rc2&id=0e6176c6d286316e9431b4f695940cfac4ffe6c2
> 
> Cheers,
> 
>   -ilia
> 
> On Thu, Feb 20, 2020 at 12:19 PM Frédéric Pierret
> <frederic.pierret@qubes-os.org> wrote:
>>
>> Hi,
>> Is anything missing here? How can I get this merged?
>>
>> Best regards,
>> Frédéric Pierret
>>
>> On 2020-02-08 20:43, Frédéric Pierret wrote:
>>> Pointer to structure array is assumed not NULL by default. It has
>>> the consequence to raise a kernel panic when it's not the case.
>>>
>>> Basically, running at least a RTX2080TI on Xen makes a bad mmio error
>>> which causes having 'mthd' pointer to be NULL in 'channv50.c'. From the
>>> code, it's assumed to be not NULL by accessing directly 'mthd->data[0]'
>>> which is the reason of the kernel panic. Simply check if the pointer
>>> is not NULL before continuing.
>>>
>>> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206299
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Frédéric Pierret (fepitre) <frederic.pierret@qubes-os.org>
>>> ---
>>>  drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
>>> index bcf32d92ee5a..50e3539f33d2 100644
>>> --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
>>> +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
>>> @@ -74,6 +74,8 @@ nv50_disp_chan_mthd(struct nv50_disp_chan *chan, int debug)
>>>
>>>       if (debug > subdev->debug)
>>>               return;
>>> +     if (!mthd)
>>> +             return;
>>>
>>>       for (i = 0; (list = mthd->data[i].mthd) != NULL; i++) {
>>>               u32 base = chan->head * mthd->addr;
>>>
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-20 18:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-08 19:43 [PATCH] nv50_disp_chan_mthd: ensure mthd is not NULL Frédéric Pierret
2020-02-20 17:19 ` Frédéric Pierret
2020-02-20 17:32   ` [Nouveau] " Ilia Mirkin
2020-02-20 18:09     ` Frédéric Pierret

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).