[PATCH] nvme: sanitize metadata bounce buffer for reads

Keith Busch kbusch at kernel.org
Mon Oct 16 13:51:31 PDT 2023


On Mon, Oct 16, 2023 at 02:41:47PM -0600, Jens Axboe wrote:
> It still looks wrong to me. If it's writing to the drive AND we fail
> copying in data, -EFAULT. But the opposite of that isn't that it's a
> read from device.
> 
> 	if (req_op(req) == REQ_OP_DRV_OUT) {
> 		ret = -EFAULT;
> 		if (copy_from_user(buf, ubuf, len))
> 			goto out_free_meta;
> 	} else {
> 		memset(buf, 0, len);
> 	}
> 
> would look more readable, as it splits it on direction, rather than on
> direction and the status of the copy. And follows the normal idioms for
> erroring on the copy condition.

Thanks! When you put it that way, the mistake was clear! Fixing for v2.



More information about the Linux-nvme mailing list