소스 검색

NVMe: Don't allow unsupported flags

The command flags can change the meaning of other fields in the command
that the driver is not prepared to handle. Specifically, the user could
passthrough an SGL flag, causing the controller to misinterpret the PRP
list the driver created, potentially corrupting memory or data.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Keith Busch 10 년 전
부모
커밋
63088ec7c8
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      drivers/nvme/host/core.c

+ 4 - 0
drivers/nvme/host/core.c

@@ -374,6 +374,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
 
 
 	if (copy_from_user(&io, uio, sizeof(io)))
 	if (copy_from_user(&io, uio, sizeof(io)))
 		return -EFAULT;
 		return -EFAULT;
+	if (io.flags)
+		return -EINVAL;
 
 
 	switch (io.opcode) {
 	switch (io.opcode) {
 	case nvme_cmd_write:
 	case nvme_cmd_write:
@@ -425,6 +427,8 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 		return -EACCES;
 		return -EACCES;
 	if (copy_from_user(&cmd, ucmd, sizeof(cmd)))
 	if (copy_from_user(&cmd, ucmd, sizeof(cmd)))
 		return -EFAULT;
 		return -EFAULT;
+	if (cmd.flags)
+		return -EINVAL;
 
 
 	memset(&c, 0, sizeof(c));
 	memset(&c, 0, sizeof(c));
 	c.common.opcode = cmd.opcode;
 	c.common.opcode = cmd.opcode;