Re: [PATCH v2] nvme: Check the PRINFO bit and the Metadata size before deciding the host buffer length
From: Christoph Hellwig <hch@lst.de>
Date: 2021-01-12 18:39:30
From: Christoph Hellwig <hch@lst.de>
Date: 2021-01-12 18:39:30
@@ -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?
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme