linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390/vfio-ap: Fix memory allocation for mdev_types array
@ 2022-10-21 14:59 Jason J. Herne
  2022-10-21 16:46 ` Matthew Rosato
  2022-10-24 12:01 ` Christian Borntraeger
  0 siblings, 2 replies; 3+ messages in thread
From: Jason J. Herne @ 2022-10-21 14:59 UTC (permalink / raw)
  To: linux-s390; +Cc: linux-kernel

The vfio-ap crypto driver fails to allocate memory for an array of
pointers used to pass supported mdev types to mdev_register_parent().

Since we only support a single mdev type, the fix is to allocate a
single entry in the ap_matrix_dev->mdev_types array.

Fixes: 63e685747784 ("s390: vfio-ap: base implementation of VFIO AP device driver")
Cc: stable@vger.kernel.org
Cc: Tony Krowiak <akrowiak@linux.ibm.com>
Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
---
 drivers/s390/crypto/vfio_ap_private.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
index 2eddd5f34ed3..976a65f32e7d 100644
--- a/drivers/s390/crypto/vfio_ap_private.h
+++ b/drivers/s390/crypto/vfio_ap_private.h
@@ -52,7 +52,7 @@ struct ap_matrix_dev {
 	struct mutex guests_lock; /* serializes access to each KVM guest */
 	struct mdev_parent parent;
 	struct mdev_type mdev_type;
-	struct mdev_type *mdev_types[];
+	struct mdev_type *mdev_types[1];
 };
 
 extern struct ap_matrix_dev *matrix_dev;
-- 
2.37.3


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

* Re: [PATCH] s390/vfio-ap: Fix memory allocation for mdev_types array
  2022-10-21 14:59 [PATCH] s390/vfio-ap: Fix memory allocation for mdev_types array Jason J. Herne
@ 2022-10-21 16:46 ` Matthew Rosato
  2022-10-24 12:01 ` Christian Borntraeger
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Rosato @ 2022-10-21 16:46 UTC (permalink / raw)
  To: Jason J. Herne, linux-s390; +Cc: linux-kernel, Christoph Hellwig

On 10/21/22 10:59 AM, Jason J. Herne wrote:
> The vfio-ap crypto driver fails to allocate memory for an array of
> pointers used to pass supported mdev types to mdev_register_parent().
> 
> Since we only support a single mdev type, the fix is to allocate a
> single entry in the ap_matrix_dev->mdev_types array.
> 
> Fixes: 63e685747784 ("s390: vfio-ap: base implementation of VFIO AP device driver")

I think you want

Fixes: da44c340c4fe ("vfio/mdev: simplify mdev_type handling")

Where *mdev_types[] was introduced.  The fix you propose is the same way Christoph (added to CC) handled vfio-ccw, LGTM.

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>

> Cc: stable@vger.kernel.org
> Cc: Tony Krowiak <akrowiak@linux.ibm.com>
> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
> ---
>  drivers/s390/crypto/vfio_ap_private.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
> index 2eddd5f34ed3..976a65f32e7d 100644
> --- a/drivers/s390/crypto/vfio_ap_private.h
> +++ b/drivers/s390/crypto/vfio_ap_private.h
> @@ -52,7 +52,7 @@ struct ap_matrix_dev {
>  	struct mutex guests_lock; /* serializes access to each KVM guest */
>  	struct mdev_parent parent;
>  	struct mdev_type mdev_type;
> -	struct mdev_type *mdev_types[];
> +	struct mdev_type *mdev_types[1];
>  };
>  
>  extern struct ap_matrix_dev *matrix_dev;


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

* Re: [PATCH] s390/vfio-ap: Fix memory allocation for mdev_types array
  2022-10-21 14:59 [PATCH] s390/vfio-ap: Fix memory allocation for mdev_types array Jason J. Herne
  2022-10-21 16:46 ` Matthew Rosato
@ 2022-10-24 12:01 ` Christian Borntraeger
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2022-10-24 12:01 UTC (permalink / raw)
  To: Jason J. Herne, linux-s390, Vasily Gorbik, Alexander Gordeev,
	Heiko Carstens
  Cc: linux-kernel, Alex Williamson, Christoph Hellwig



Am 21.10.22 um 16:59 schrieb Jason J. Herne:
> The vfio-ap crypto driver fails to allocate memory for an array of
> pointers used to pass supported mdev types to mdev_register_parent().
> 
> Since we only support a single mdev type, the fix is to allocate a
> single entry in the ap_matrix_dev->mdev_types array.
> 
> Fixes: 63e685747784 ("s390: vfio-ap: base implementation of VFIO AP device driver")
> Cc: stable@vger.kernel.org
> Cc: Tony Krowiak <akrowiak@linux.ibm.com>
> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
> ---
>   drivers/s390/crypto/vfio_ap_private.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
> index 2eddd5f34ed3..976a65f32e7d 100644
> --- a/drivers/s390/crypto/vfio_ap_private.h
> +++ b/drivers/s390/crypto/vfio_ap_private.h
> @@ -52,7 +52,7 @@ struct ap_matrix_dev {
>   	struct mutex guests_lock; /* serializes access to each KVM guest */
>   	struct mdev_parent parent;
>   	struct mdev_type mdev_type;
> -	struct mdev_type *mdev_types[];
> +	struct mdev_type *mdev_types[1];
>   };
>   
>   extern struct ap_matrix_dev *matrix_dev;


Thanks, will go via s390-fixes.

Alex, FYI.

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

end of thread, other threads:[~2022-10-24 13:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 14:59 [PATCH] s390/vfio-ap: Fix memory allocation for mdev_types array Jason J. Herne
2022-10-21 16:46 ` Matthew Rosato
2022-10-24 12:01 ` Christian Borntraeger

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