Re: [PATCH v7 17/22] s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/26/2018 09:54 PM, Christian Borntraeger wrote:
> From: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>
> 
> Introduces ioctl access to the VFIO AP Matrix device driver
> by implementing the VFIO_DEVICE_GET_INFO ioctl. This ioctl
> provides the VFIO AP Matrix device driver information to the
> guest machine.
> 
> Signed-off-by: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>
> Reviewed-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
> Acked-by: Halil Pasic <pasic@xxxxxxxxxxxxx>
> Tested-by: Michael Mueller <mimu@xxxxxxxxxxxxx>
> Tested-by: Farhan Ali <alifm@xxxxxxxxxxxxx>
> Tested-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
> Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
> ---
>  drivers/s390/crypto/vfio_ap_ops.c | 43 +++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index d06067a23000..01c429cb51d5 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -867,6 +867,48 @@ static void vfio_ap_mdev_release(struct mdev_device *mdev)
>  	module_put(THIS_MODULE);
>  }
>  
> +static int vfio_ap_mdev_get_device_info(unsigned long arg)
> +{
> +	unsigned long minsz;
> +	struct vfio_device_info info;
> +
> +	minsz = offsetofend(struct vfio_device_info, num_irqs);
> +
> +	if (copy_from_user(&info, (void __user *)arg, minsz))
> +		return -EFAULT;
> +
> +	if (info.argsz < minsz) {
> +		pr_warn("%s: Argument size %u less than min size %li\n",
> +			VFIO_AP_MODULE_NAME, info.argsz, minsz);

Do you really need this pr_warn here? The -EINVAL should give a clear
indication about the problem already. (and in the worst case, a
malicious userspace program could use it to flood the kernel log)

> +		return -EINVAL;
> +	}
> +
> +	info.flags = VFIO_DEVICE_FLAGS_AP;
> +	info.num_regions = 0;
> +	info.num_irqs = 0;
> +
> +	return copy_to_user((void __user *)arg, &info, minsz);
> +}
> +
> +static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev,
> +				    unsigned int cmd, unsigned long arg)
> +{
> +	int ret;
> +
> +	switch (cmd) {
> +	case VFIO_DEVICE_GET_INFO:
> +		ret = vfio_ap_mdev_get_device_info(arg);
> +		break;
> +	default:
> +		pr_warn("%s: ioctl command %d is not a supported command\n",
> +			VFIO_AP_MODULE_NAME, cmd);

I'd also remove this pr_warn - the -EOPNOTSUPP should be enough.

> +		ret = -EOPNOTSUPP;
> +		break;

"break;" is also not required here.

> +	}
> +
> +	return ret;
> +}
> +
>  static const struct mdev_parent_ops vfio_ap_matrix_ops = {
>  	.owner			= THIS_MODULE,
>  	.supported_type_groups	= vfio_ap_mdev_type_groups,
> @@ -875,6 +917,7 @@ static const struct mdev_parent_ops vfio_ap_matrix_ops = {
>  	.remove			= vfio_ap_mdev_remove,
>  	.open			= vfio_ap_mdev_open,
>  	.release		= vfio_ap_mdev_release,
> +	.ioctl			= vfio_ap_mdev_ioctl,
>  };
>  
>  int vfio_ap_mdev_register(void)
> 

 Thomas
--
To unsubscribe from this list: send the line "unsubscribe linux-s390" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux