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: <aa455c36-83be-7757-7171-05460a459a2e@linux.intel.com>
Date:   Wed, 9 Aug 2023 18:16:19 +0800
From:   Baolu Lu <baolu.lu@...ux.intel.com>
To:     Yi Liu <yi.l.liu@...el.com>, joro@...tes.org,
        alex.williamson@...hat.com, jgg@...dia.com, kevin.tian@...el.com,
        robin.murphy@....com
Cc:     baolu.lu@...ux.intel.com, cohuck@...hat.com, eric.auger@...hat.com,
        nicolinc@...dia.com, kvm@...r.kernel.org, mjrosato@...ux.ibm.com,
        chao.p.peng@...ux.intel.com, yi.y.sun@...ux.intel.com,
        peterx@...hat.com, jasowang@...hat.com,
        shameerali.kolothum.thodi@...wei.com, lulu@...hat.com,
        suravee.suthikulpanit@....com, iommu@...ts.linux.dev,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        zhenzhong.duan@...el.com
Subject: Re: [PATCH v6 3/4] iommufd: Add IOMMU_GET_HW_INFO

On 2023/8/8 23:35, Yi Liu wrote:
> +static int iommufd_fill_hw_info(struct device *dev, void __user *user_ptr,
> +				unsigned int *length, u32 *type)
> +{
> +	const struct iommu_ops *ops;
> +	unsigned int data_len;
> +	void *data;
> +	int rc = 0;
> +
> +	ops = dev_iommu_ops(dev);
> +	if (!ops->hw_info) {
> +		*length = 0;
> +		*type = IOMMU_HW_INFO_TYPE_NONE;
> +		return 0;
> +	}
> +
> +	data = ops->hw_info(dev, &data_len, type);
> +	if (IS_ERR(data))
> +		return PTR_ERR(data);
> +
> +	/*
> +	 * drivers that have hw_info callback should have a unique
> +	 * iommu_hw_info_type.
> +	 */
> +	if (WARN_ON_ONCE(*type == IOMMU_HW_INFO_TYPE_NONE)) {
> +		rc = -ENODEV;
> +		goto err_free;
> +	}
> +
> +	*length = min(*length, data_len);
> +	if (copy_to_user(user_ptr, data, *length)) {

copy_to_user() returns the number of bytes that were successfully
copied, right?

If so, isn't it always failure case? Or I missed anything?

> +		rc = -EFAULT;
> +		goto err_free;

nit: this goto is unnecessary.

> +	}
> +
> +err_free:
> +	kfree(data);
> +	return rc;
> +}

Best regards,
baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ