lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 27 Mar 2021 08:51:45 +0100
From:   "javier@...igon.com" <javier@...igon.com>
To:     Niklas Cassel <Niklas.Cassel@....com>
Cc:     Keith Busch <kbusch@...nel.org>, Jens Axboe <axboe@...com>,
        Christoph Hellwig <hch@....de>,
        Sagi Grimberg <sagi@...mberg.me>,
        "minwoo.im.dev@...il.com" <minwoo.im.dev@...il.com>,
        "linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: nvme: disallow passthru cmd from targeting a nsid != nsid of the
 block dev

On 26.03.2021 19:48, Niklas Cassel wrote:
>From: Niklas Cassel <niklas.cassel@....com>
>
>When a passthru command targets a specific namespace, the ns parameter to
>nvme_user_cmd()/nvme_user_cmd64() is set. However, there is currently no
>validation that the nsid specified in the passthru command targets the
>namespace/nsid represented by the block device that the ioctl was
>performed on.
>
>Add a check that validates that the nsid in the passthru command matches
>that of the supplied namespace.
>
>Signed-off-by: Niklas Cassel <niklas.cassel@....com>
>---
>Changes since v1:
>-Added error print.
>
> drivers/nvme/host/core.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
>diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>index f13eb4ded95f..a50352ea3f7b 100644
>--- a/drivers/nvme/host/core.c
>+++ b/drivers/nvme/host/core.c
>@@ -1599,6 +1599,12 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
> 		return -EFAULT;
> 	if (cmd.flags)
> 		return -EINVAL;
>+	if (ns && cmd.nsid != ns->head->ns_id) {
>+		dev_err(ctrl->device,
>+			"%s: nsid (%u) in cmd does not match nsid (%u) of namespace\n",
>+			current->comm, cmd.nsid, ns->head->ns_id);
>+		return -EINVAL;
>+	}
>
> 	memset(&c, 0, sizeof(c));
> 	c.common.opcode = cmd.opcode;
>@@ -1643,6 +1649,12 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
> 		return -EFAULT;
> 	if (cmd.flags)
> 		return -EINVAL;
>+	if (ns && cmd.nsid != ns->head->ns_id) {
>+		dev_err(ctrl->device,
>+			"%s: nsid (%u) in cmd does not match nsid (%u) of namespace\n",
>+			current->comm, cmd.nsid, ns->head->ns_id);
>+		return -EINVAL;
>+	}
>
> 	memset(&c, 0, sizeof(c));
> 	c.common.opcode = cmd.opcode;
>-- 
>2.30.2

Looks good to me

Reviewed-by: Javier González <javier@...igon.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ