From: Keith Busch Date: Wed, 24 Feb 2016 16:15:57 +0000 (-0700) Subject: NVMe: Don't allow unsupported flags X-Git-Tag: v4.1.12-102.0.20170601_1400~113 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a05828761ff8e93d29f8b3751d71c28a424e8c3b;p=users%2Fjedix%2Flinux-maple.git 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 Reviewed-by: Jon Derrick Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Signed-off-by: Jens Axboe (cherry picked from commit 63088ec7c8eadfe08b96127a41b385ec9742dace) Orabug: 25130845 Signed-off-by: Ashok Vairavan Reviewed-by: Martin K. Petersen --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 7f8201522aabd..3f767d0e8461c 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -400,6 +400,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) if (copy_from_user(&io, uio, sizeof(io))) return -EFAULT; + if (io.flags) + return -EINVAL; switch (io.opcode) { case nvme_cmd_write: @@ -451,6 +453,8 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, return -EACCES; if (copy_from_user(&cmd, ucmd, sizeof(cmd))) return -EFAULT; + if (cmd.flags) + return -EINVAL; memset(&c, 0, sizeof(c)); c.common.opcode = cmd.opcode;