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] [thread-next>] [day] [month] [year] [list]
Message-ID: <af3d6c67-e045-770f-82ff-dd8e691c1317@linux.ibm.com>
Date:   Fri, 18 Jun 2021 14:11:23 -0400
From:   Tony Krowiak <akrowiak@...ux.ibm.com>
To:     "Jason J. Herne" <jjherne@...ux.ibm.com>,
        linux-s390@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, pasic@...ux.ibm.com, jgg@...dia.com
Subject: Re: [PATCH v2] s390/vfio-ap: Fix module unload memory leak of
 matrix_dev



On 6/18/21 1:12 PM, Jason J. Herne wrote:
> vfio_ap_matrix_dev_release is shadowing the global matrix_dev with a NULL
> pointer. Driver data for the matrix device is never set and so
> dev_get_drvdata() always returns NULL. When release is called we end up
> not freeing matrix_dev. The fix is to remove the shadow variable and get
> the correct pointer from the device using container_of. We'll also NULL
> the global to prevent any future use.
>
> Signed-off-by: Jason J. Herne <jjherne@...ux.ibm.com>
> ---
>   drivers/s390/crypto/vfio_ap_drv.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c
> index 7dc72cb718b0..40e66cb363d1 100644
> --- a/drivers/s390/crypto/vfio_ap_drv.c
> +++ b/drivers/s390/crypto/vfio_ap_drv.c
> @@ -82,9 +82,8 @@ static void vfio_ap_queue_dev_remove(struct ap_device *apdev)
>   
>   static void vfio_ap_matrix_dev_release(struct device *dev)
>   {
> -	struct ap_matrix_dev *matrix_dev = dev_get_drvdata(dev);
> -
> -	kfree(matrix_dev);
> +	kfree(container_of(dev, struct ap_matrix_dev, device));

I suppose if we're not going to assume that the release is being
called to free the global matrix_dev, then if you are going to
retrieve it using container_of(), then maybe we should verify
the retrieved pointer is the same as the global matrix_dev?

> +	matrix_dev = NULL;
>   }
>   
>   static int matrix_bus_match(struct device *dev, struct device_driver *drv)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ