[PATCH v2] nvme: Check the PRINFO bit and the Metadata size before deciding the host buffer length

Rajashekar, Revanth revanth.rajashekar at intel.com
Wed Jan 13 11:57:18 EST 2021


Hi Christoph,
Thanks for reviewing.

On 1/12/2021 11:39 AM, Christoph Hellwig wrote:
>> @@ -1546,6 +1546,11 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
>>  	meta_len = (io.nblocks + 1) * ns->ms;
>>  	metadata = nvme_to_user_ptr(io.metadata);
>>
>> +	if (io.control & NVME_RW_PRINFO_PRACT && ns->ms == 8) {
>> +		meta_len = 0;
>> +		metadata = NULL;
>> +	}
>> +
> Wouldn't something like:
>
> 	if ((io.control & NVME_RW_PRINFO_PRACT) &&
> 	    ns->ms == sizeof(struct t10_pi_tuple)) {
> 		/*
> 		 * Protection information is stripped/inserted by the
> 		 * controller.
> 		 */
> 		if (nvme_to_user_ptr(io.metadata))
> 			return -EINVAL;
> 		meta_len = 0;
> 		metadata = NULL;
> 	} else {
> 	 	meta_len = (io.nblocks + 1) * ns->ms;
> 		metadata = nvme_to_user_ptr(io.metadata);
> 	}
>
> make a little more sense?
Yes! it definitely makes more sense.
Will send out a v3 for this patch.

Thanks!
Revanth



More information about the Linux-nvme mailing list