2019-04-19 18:21:46

by Greg Kurz

[permalink] [raw]
Subject: [PATCH] vfio-pci/nvlink2: Fix potential VMA leak

If vfio_pci_register_dev_region() fails then we should rollback
previous changes, ie. unmap the ATSD registers.

Signed-off-by: Greg Kurz <[email protected]>
---
drivers/vfio/pci/vfio_pci_nvlink2.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
index 32f695ffe128..50fe3c4f7feb 100644
--- a/drivers/vfio/pci/vfio_pci_nvlink2.c
+++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
@@ -472,6 +472,8 @@ int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev)
return 0;

free_exit:
+ if (data->base)
+ memunmap(data->base);
kfree(data);

return ret;



2019-04-26 07:51:42

by Alexey Kardashevskiy

[permalink] [raw]
Subject: Re: [PATCH] vfio-pci/nvlink2: Fix potential VMA leak



On 20/04/2019 01:37, Greg Kurz wrote:
> If vfio_pci_register_dev_region() fails then we should rollback
> previous changes, ie. unmap the ATSD registers.
>
> Signed-off-by: Greg Kurz <[email protected]>
> ---
> drivers/vfio/pci/vfio_pci_nvlink2.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
> index 32f695ffe128..50fe3c4f7feb 100644
> --- a/drivers/vfio/pci/vfio_pci_nvlink2.c
> +++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
> @@ -472,6 +472,8 @@ int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev)
> return 0;
>
> free_exit:
> + if (data->base)
> + memunmap(data->base);
> kfree(data);
>
> return ret;
>

Reviewed-by: Alexey Kardashevskiy <[email protected]>


--
Alexey

2019-05-06 22:00:39

by Alex Williamson

[permalink] [raw]
Subject: Re: [PATCH] vfio-pci/nvlink2: Fix potential VMA leak

On Fri, 19 Apr 2019 17:37:17 +0200
Greg Kurz <[email protected]> wrote:

> If vfio_pci_register_dev_region() fails then we should rollback
> previous changes, ie. unmap the ATSD registers.
>
> Signed-off-by: Greg Kurz <[email protected]>
> ---

Applied to vfio next branch for v5.2 with Alexey's R-b. Thanks!

Alex

> drivers/vfio/pci/vfio_pci_nvlink2.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
> index 32f695ffe128..50fe3c4f7feb 100644
> --- a/drivers/vfio/pci/vfio_pci_nvlink2.c
> +++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
> @@ -472,6 +472,8 @@ int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev)
> return 0;
>
> free_exit:
> + if (data->base)
> + memunmap(data->base);
> kfree(data);
>
> return ret;
>

2019-05-07 01:55:15

by Sam Bobroff

[permalink] [raw]
Subject: Re: [PATCH] vfio-pci/nvlink2: Fix potential VMA leak

On Mon, May 06, 2019 at 03:58:45PM -0600, Alex Williamson wrote:
> On Fri, 19 Apr 2019 17:37:17 +0200
> Greg Kurz <[email protected]> wrote:
>
> > If vfio_pci_register_dev_region() fails then we should rollback
> > previous changes, ie. unmap the ATSD registers.
> >
> > Signed-off-by: Greg Kurz <[email protected]>
> > ---
>
> Applied to vfio next branch for v5.2 with Alexey's R-b. Thanks!
>
> Alex

Should this have a fixes tag? e.g.:
Fixes: 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver")

> > drivers/vfio/pci/vfio_pci_nvlink2.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
> > index 32f695ffe128..50fe3c4f7feb 100644
> > --- a/drivers/vfio/pci/vfio_pci_nvlink2.c
> > +++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
> > @@ -472,6 +472,8 @@ int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev)
> > return 0;
> >
> > free_exit:
> > + if (data->base)
> > + memunmap(data->base);
> > kfree(data);
> >
> > return ret;
> >
>


Attachments:
(No filename) (1.07 kB)
signature.asc (499.00 B)
Download all attachments

2019-05-07 07:41:37

by Greg Kurz

[permalink] [raw]
Subject: Re: [PATCH] vfio-pci/nvlink2: Fix potential VMA leak

On Tue, 7 May 2019 11:52:44 +1000
Sam Bobroff <[email protected]> wrote:

> On Mon, May 06, 2019 at 03:58:45PM -0600, Alex Williamson wrote:
> > On Fri, 19 Apr 2019 17:37:17 +0200
> > Greg Kurz <[email protected]> wrote:
> >
> > > If vfio_pci_register_dev_region() fails then we should rollback
> > > previous changes, ie. unmap the ATSD registers.
> > >
> > > Signed-off-by: Greg Kurz <[email protected]>
> > > ---
> >
> > Applied to vfio next branch for v5.2 with Alexey's R-b. Thanks!
> >
> > Alex
>
> Should this have a fixes tag? e.g.:
> Fixes: 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver")
>

Oops... you're right.

Alex, can you add the above tag ?

> > > drivers/vfio/pci/vfio_pci_nvlink2.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
> > > index 32f695ffe128..50fe3c4f7feb 100644
> > > --- a/drivers/vfio/pci/vfio_pci_nvlink2.c
> > > +++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
> > > @@ -472,6 +472,8 @@ int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev)
> > > return 0;
> > >
> > > free_exit:
> > > + if (data->base)
> > > + memunmap(data->base);
> > > kfree(data);
> > >
> > > return ret;
> > >
> >


Attachments:
(No filename) (849.00 B)
OpenPGP digital signature

2019-05-07 17:27:13

by Alex Williamson

[permalink] [raw]
Subject: Re: [PATCH] vfio-pci/nvlink2: Fix potential VMA leak

On Tue, 7 May 2019 09:01:45 +0200
Greg Kurz <[email protected]> wrote:

> On Tue, 7 May 2019 11:52:44 +1000
> Sam Bobroff <[email protected]> wrote:
>
> > On Mon, May 06, 2019 at 03:58:45PM -0600, Alex Williamson wrote:
> > > On Fri, 19 Apr 2019 17:37:17 +0200
> > > Greg Kurz <[email protected]> wrote:
> > >
> > > > If vfio_pci_register_dev_region() fails then we should rollback
> > > > previous changes, ie. unmap the ATSD registers.
> > > >
> > > > Signed-off-by: Greg Kurz <[email protected]>
> > > > ---
> > >
> > > Applied to vfio next branch for v5.2 with Alexey's R-b. Thanks!
> > >
> > > Alex
> >
> > Should this have a fixes tag? e.g.:
> > Fixes: 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver")
> >
>
> Oops... you're right.
>
> Alex, can you add the above tag ?

Added. Thanks,

Alex