All of lore.kernel.org
 help / color / mirror / Atom feed
* don't allow unprivileged passthrough on partitions
@ 2023-01-08 16:50 ` Christoph Hellwig
  2023-01-08 16:50   ` [PATCH 1/3] nvme: remove __nvme_ioctl Christoph Hellwig
                     ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-01-08 16:50 UTC (permalink / raw)
  To: Keith Busch, Sagi Grimberg, Chaitanya Kulkarni; +Cc: Kanchan Joshi, linux-nvme

Hi all,

this series fixes ensures that unprivileged passthrough can't be
used on partitions.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/3] nvme: remove __nvme_ioctl
  2023-01-08 16:50 ` don't allow unprivileged passthrough on partitions Christoph Hellwig
@ 2023-01-08 16:50   ` Christoph Hellwig
  2023-01-09  7:34     ` Chaitanya Kulkarni
  2023-01-12 13:20     ` Hannes Reinecke
  2023-01-08 16:50   ` [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path Christoph Hellwig
                     ` (3 subsequent siblings)
  4 siblings, 2 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-01-08 16:50 UTC (permalink / raw)
  To: Keith Busch, Sagi Grimberg, Chaitanya Kulkarni; +Cc: Kanchan Joshi, linux-nvme

Open code __nvme_ioctl in the two callers to make future changes that
pass down additional paramters in the ioctl path easier.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/ioctl.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index a8639919237e6a..c12b7c445fc0b2 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -695,28 +695,26 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
 	}
 }
 
-static int __nvme_ioctl(struct nvme_ns *ns, unsigned int cmd, void __user *arg,
-			fmode_t mode)
-{
-	if (is_ctrl_ioctl(cmd))
-		return nvme_ctrl_ioctl(ns->ctrl, cmd, arg, mode);
-	return nvme_ns_ioctl(ns, cmd, arg, mode);
-}
-
 int nvme_ioctl(struct block_device *bdev, fmode_t mode,
 		unsigned int cmd, unsigned long arg)
 {
 	struct nvme_ns *ns = bdev->bd_disk->private_data;
+	void __user *argp = (void __user *)arg;
 
-	return __nvme_ioctl(ns, cmd, (void __user *)arg, mode);
+	if (is_ctrl_ioctl(cmd))
+		return nvme_ctrl_ioctl(ns->ctrl, cmd, argp, mode);
+	return nvme_ns_ioctl(ns, cmd, argp, mode);
 }
 
 long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct nvme_ns *ns =
 		container_of(file_inode(file)->i_cdev, struct nvme_ns, cdev);
+	void __user *argp = (void __user *)arg;
 
-	return __nvme_ioctl(ns, cmd, (void __user *)arg, file->f_mode);
+	if (is_ctrl_ioctl(cmd))
+		return nvme_ctrl_ioctl(ns->ctrl, cmd, argp, file->f_mode);
+	return nvme_ns_ioctl(ns, cmd, argp, file->f_mode);
 }
 
 static int nvme_uring_cmd_checks(unsigned int issue_flags)
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path
  2023-01-08 16:50 ` don't allow unprivileged passthrough on partitions Christoph Hellwig
  2023-01-08 16:50   ` [PATCH 1/3] nvme: remove __nvme_ioctl Christoph Hellwig
@ 2023-01-08 16:50   ` Christoph Hellwig
  2023-01-09  7:39     ` Chaitanya Kulkarni
  2023-01-12 13:21     ` Hannes Reinecke
  2023-01-08 16:50   ` [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions Christoph Hellwig
                     ` (2 subsequent siblings)
  4 siblings, 2 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-01-08 16:50 UTC (permalink / raw)
  To: Keith Busch, Sagi Grimberg, Chaitanya Kulkarni; +Cc: Kanchan Joshi, linux-nvme

To prepare for passing down more information, replace the boolean
vec argument with a more extensible flags one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/ioctl.c | 53 +++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index c12b7c445fc0b2..999ebc1b700056 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -8,6 +8,10 @@
 #include <linux/io_uring.h>
 #include "nvme.h"
 
+enum {
+	NVME_IOCTL_VEC		= (1 << 0),
+};
+
 static bool nvme_cmd_allowed(struct nvme_ns *ns, struct nvme_command *c,
 		fmode_t mode)
 {
@@ -150,7 +154,7 @@ static struct request *nvme_alloc_user_request(struct request_queue *q,
 static int nvme_map_user_request(struct request *req, u64 ubuffer,
 		unsigned bufflen, void __user *meta_buffer, unsigned meta_len,
 		u32 meta_seed, void **metap, struct io_uring_cmd *ioucmd,
-		bool vec)
+		unsigned int flags)
 {
 	struct request_queue *q = req->q;
 	struct nvme_ns *ns = q->queuedata;
@@ -163,7 +167,7 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
 		struct iov_iter iter;
 
 		/* fixedbufs is only for non-vectored io */
-		if (WARN_ON_ONCE(vec))
+		if (WARN_ON_ONCE(flags & NVME_IOCTL_VEC))
 			return -EINVAL;
 		ret = io_uring_cmd_import_fixed(ubuffer, bufflen,
 				rq_data_dir(req), &iter, ioucmd);
@@ -172,8 +176,8 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
 		ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
 	} else {
 		ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer),
-				bufflen, GFP_KERNEL, vec, 0, 0,
-				rq_data_dir(req));
+				bufflen, GFP_KERNEL, flags & NVME_IOCTL_VEC, 0,
+				0, rq_data_dir(req));
 	}
 
 	if (ret)
@@ -203,9 +207,9 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
 }
 
 static int nvme_submit_user_cmd(struct request_queue *q,
-		struct nvme_command *cmd, u64 ubuffer,
-		unsigned bufflen, void __user *meta_buffer, unsigned meta_len,
-		u32 meta_seed, u64 *result, unsigned timeout, bool vec)
+		struct nvme_command *cmd, u64 ubuffer, unsigned bufflen,
+		void __user *meta_buffer, unsigned meta_len, u32 meta_seed,
+		u64 *result, unsigned timeout, unsigned int flags)
 {
 	struct nvme_ctrl *ctrl;
 	struct request *req;
@@ -221,7 +225,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,
 	req->timeout = timeout;
 	if (ubuffer && bufflen) {
 		ret = nvme_map_user_request(req, ubuffer, bufflen, meta_buffer,
-				meta_len, meta_seed, &meta, NULL, vec);
+				meta_len, meta_seed, &meta, NULL, flags);
 		if (ret)
 			return ret;
 	}
@@ -304,10 +308,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
 	c.rw.apptag = cpu_to_le16(io.apptag);
 	c.rw.appmask = cpu_to_le16(io.appmask);
 
-	return nvme_submit_user_cmd(ns->queue, &c,
-			io.addr, length,
-			metadata, meta_len, lower_32_bits(io.slba), NULL, 0,
-			false);
+	return nvme_submit_user_cmd(ns->queue, &c, io.addr, length, metadata,
+			meta_len, lower_32_bits(io.slba), NULL, 0, 0);
 }
 
 static bool nvme_validate_passthru_nsid(struct nvme_ctrl *ctrl,
@@ -360,9 +362,8 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 		timeout = msecs_to_jiffies(cmd.timeout_ms);
 
 	status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c,
-			cmd.addr, cmd.data_len,
-			nvme_to_user_ptr(cmd.metadata), cmd.metadata_len,
-			0, &result, timeout, false);
+			cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata),
+			cmd.metadata_len, 0, &result, timeout, 0);
 
 	if (status >= 0) {
 		if (put_user(result, &ucmd->result))
@@ -373,8 +374,8 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 }
 
 static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
-			struct nvme_passthru_cmd64 __user *ucmd, bool vec,
-			fmode_t mode)
+		struct nvme_passthru_cmd64 __user *ucmd, unsigned int flags,
+		fmode_t mode)
 {
 	struct nvme_passthru_cmd64 cmd;
 	struct nvme_command c;
@@ -408,9 +409,8 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 		timeout = msecs_to_jiffies(cmd.timeout_ms);
 
 	status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c,
-			cmd.addr, cmd.data_len,
-			nvme_to_user_ptr(cmd.metadata), cmd.metadata_len,
-			0, &cmd.result, timeout, vec);
+			cmd.addr, cmd.data_len, nvme_to_user_ptr(cmd.metadata),
+			cmd.metadata_len, 0, &cmd.result, timeout, flags);
 
 	if (status >= 0) {
 		if (put_user(cmd.result, &ucmd->result))
@@ -643,7 +643,7 @@ static int nvme_ctrl_ioctl(struct nvme_ctrl *ctrl, unsigned int cmd,
 	case NVME_IOCTL_ADMIN_CMD:
 		return nvme_user_cmd(ctrl, NULL, argp, mode);
 	case NVME_IOCTL_ADMIN64_CMD:
-		return nvme_user_cmd64(ctrl, NULL, argp, false, mode);
+		return nvme_user_cmd64(ctrl, NULL, argp, 0, mode);
 	default:
 		return sed_ioctl(ctrl->opal_dev, cmd, argp);
 	}
@@ -670,6 +670,8 @@ struct nvme_user_io32 {
 static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
 		void __user *argp, fmode_t mode)
 {
+	unsigned int flags = 0;
+
 	switch (cmd) {
 	case NVME_IOCTL_ID:
 		force_successful_syscall_return();
@@ -686,10 +688,11 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
 #endif
 	case NVME_IOCTL_SUBMIT_IO:
 		return nvme_submit_io(ns, argp);
-	case NVME_IOCTL_IO64_CMD:
-		return nvme_user_cmd64(ns->ctrl, ns, argp, false, mode);
 	case NVME_IOCTL_IO64_CMD_VEC:
-		return nvme_user_cmd64(ns->ctrl, ns, argp, true, mode);
+		flags |= NVME_IOCTL_VEC;
+		fallthrough;
+	case NVME_IOCTL_IO64_CMD:
+		return nvme_user_cmd64(ns->ctrl, ns, argp, flags, mode);
 	default:
 		return -ENOTTY;
 	}
@@ -962,7 +965,7 @@ long nvme_dev_ioctl(struct file *file, unsigned int cmd,
 	case NVME_IOCTL_ADMIN_CMD:
 		return nvme_user_cmd(ctrl, NULL, argp, file->f_mode);
 	case NVME_IOCTL_ADMIN64_CMD:
-		return nvme_user_cmd64(ctrl, NULL, argp, false, file->f_mode);
+		return nvme_user_cmd64(ctrl, NULL, argp, 0, file->f_mode);
 	case NVME_IOCTL_IO_CMD:
 		return nvme_dev_user_cmd(ctrl, argp, file->f_mode);
 	case NVME_IOCTL_RESET:
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions
  2023-01-08 16:50 ` don't allow unprivileged passthrough on partitions Christoph Hellwig
  2023-01-08 16:50   ` [PATCH 1/3] nvme: remove __nvme_ioctl Christoph Hellwig
  2023-01-08 16:50   ` [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path Christoph Hellwig
@ 2023-01-08 16:50   ` Christoph Hellwig
  2023-01-09  7:40     ` Chaitanya Kulkarni
  2023-01-12 13:23     ` Hannes Reinecke
  2023-01-09 10:45   ` Kanchan Joshi
  2023-01-09 15:13   ` Keith Busch
  4 siblings, 2 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-01-08 16:50 UTC (permalink / raw)
  To: Keith Busch, Sagi Grimberg, Chaitanya Kulkarni; +Cc: Kanchan Joshi, linux-nvme

Passthrough commands can always access the entire device, and thus
submitting them on partitions is an privelege escalation.

In hindsight we should have never allowed any passthrough commands on
partitions, but it's probably too late to change that decision now.

Fixes: e4fbcf32c860 ("nvme: identify-namespace without CAP_SYS_ADMIN")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/ioctl.c | 47 ++++++++++++++++++++++++++-------------
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 999ebc1b700056..06f52db34be9bd 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -10,16 +10,24 @@
 
 enum {
 	NVME_IOCTL_VEC		= (1 << 0),
+	NVME_IOCTL_PARTITION	= (1 << 1),
 };
 
 static bool nvme_cmd_allowed(struct nvme_ns *ns, struct nvme_command *c,
-		fmode_t mode)
+		unsigned int flags, fmode_t mode)
 {
 	u32 effects;
 
 	if (capable(CAP_SYS_ADMIN))
 		return true;
 
+	/*
+	 * Do not allow unprivileged passthrough on partitions, as that allows an
+	 * escape from the containment of the partition.
+	 */
+	if (flags & NVME_IOCTL_PARTITION)
+		return false;
+
 	/*
 	 * Do not allow unprivileged processes to send vendor specific or fabrics
 	 * commands as we can't be sure about their effects.
@@ -327,7 +335,8 @@ static bool nvme_validate_passthru_nsid(struct nvme_ctrl *ctrl,
 }
 
 static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
-			struct nvme_passthru_cmd __user *ucmd, fmode_t mode)
+		struct nvme_passthru_cmd __user *ucmd, unsigned int flags,
+		fmode_t mode)
 {
 	struct nvme_passthru_cmd cmd;
 	struct nvme_command c;
@@ -355,7 +364,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 	c.common.cdw14 = cpu_to_le32(cmd.cdw14);
 	c.common.cdw15 = cpu_to_le32(cmd.cdw15);
 
-	if (!nvme_cmd_allowed(ns, &c, mode))
+	if (!nvme_cmd_allowed(ns, &c, 0, mode))
 		return -EACCES;
 
 	if (cmd.timeout_ms)
@@ -402,7 +411,7 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 	c.common.cdw14 = cpu_to_le32(cmd.cdw14);
 	c.common.cdw15 = cpu_to_le32(cmd.cdw15);
 
-	if (!nvme_cmd_allowed(ns, &c, mode))
+	if (!nvme_cmd_allowed(ns, &c, flags, mode))
 		return -EACCES;
 
 	if (cmd.timeout_ms)
@@ -571,7 +580,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
 	c.common.cdw14 = cpu_to_le32(READ_ONCE(cmd->cdw14));
 	c.common.cdw15 = cpu_to_le32(READ_ONCE(cmd->cdw15));
 
-	if (!nvme_cmd_allowed(ns, &c, ioucmd->file->f_mode))
+	if (!nvme_cmd_allowed(ns, &c, 0, ioucmd->file->f_mode))
 		return -EACCES;
 
 	d.metadata = READ_ONCE(cmd->metadata);
@@ -641,7 +650,7 @@ static int nvme_ctrl_ioctl(struct nvme_ctrl *ctrl, unsigned int cmd,
 {
 	switch (cmd) {
 	case NVME_IOCTL_ADMIN_CMD:
-		return nvme_user_cmd(ctrl, NULL, argp, mode);
+		return nvme_user_cmd(ctrl, NULL, argp, 0, mode);
 	case NVME_IOCTL_ADMIN64_CMD:
 		return nvme_user_cmd64(ctrl, NULL, argp, 0, mode);
 	default:
@@ -668,16 +677,14 @@ struct nvme_user_io32 {
 #endif /* COMPAT_FOR_U64_ALIGNMENT */
 
 static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
-		void __user *argp, fmode_t mode)
+		void __user *argp, unsigned int flags, fmode_t mode)
 {
-	unsigned int flags = 0;
-
 	switch (cmd) {
 	case NVME_IOCTL_ID:
 		force_successful_syscall_return();
 		return ns->head->ns_id;
 	case NVME_IOCTL_IO_CMD:
-		return nvme_user_cmd(ns->ctrl, ns, argp, mode);
+		return nvme_user_cmd(ns->ctrl, ns, argp, flags, mode);
 	/*
 	 * struct nvme_user_io can have different padding on some 32-bit ABIs.
 	 * Just accept the compat version as all fields that are used are the
@@ -703,10 +710,14 @@ int nvme_ioctl(struct block_device *bdev, fmode_t mode,
 {
 	struct nvme_ns *ns = bdev->bd_disk->private_data;
 	void __user *argp = (void __user *)arg;
+	unsigned int flags = 0;
+
+	if (bdev_is_partition(bdev))
+		flags |= NVME_IOCTL_PARTITION;
 
 	if (is_ctrl_ioctl(cmd))
 		return nvme_ctrl_ioctl(ns->ctrl, cmd, argp, mode);
-	return nvme_ns_ioctl(ns, cmd, argp, mode);
+	return nvme_ns_ioctl(ns, cmd, argp, flags, mode);
 }
 
 long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -717,7 +728,7 @@ long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	if (is_ctrl_ioctl(cmd))
 		return nvme_ctrl_ioctl(ns->ctrl, cmd, argp, file->f_mode);
-	return nvme_ns_ioctl(ns, cmd, argp, file->f_mode);
+	return nvme_ns_ioctl(ns, cmd, argp, 0, file->f_mode);
 }
 
 static int nvme_uring_cmd_checks(unsigned int issue_flags)
@@ -807,6 +818,10 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
 	void __user *argp = (void __user *)arg;
 	struct nvme_ns *ns;
 	int srcu_idx, ret = -EWOULDBLOCK;
+	unsigned int flags = 0;
+
+	if (bdev_is_partition(bdev))
+		flags |= NVME_IOCTL_PARTITION;
 
 	srcu_idx = srcu_read_lock(&head->srcu);
 	ns = nvme_find_path(head);
@@ -822,7 +837,7 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
 		return nvme_ns_head_ctrl_ioctl(ns, cmd, argp, head, srcu_idx,
 					mode);
 
-	ret = nvme_ns_ioctl(ns, cmd, argp, mode);
+	ret = nvme_ns_ioctl(ns, cmd, argp, flags, mode);
 out_unlock:
 	srcu_read_unlock(&head->srcu, srcu_idx);
 	return ret;
@@ -847,7 +862,7 @@ long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
 		return nvme_ns_head_ctrl_ioctl(ns, cmd, argp, head, srcu_idx,
 				file->f_mode);
 
-	ret = nvme_ns_ioctl(ns, cmd, argp, file->f_mode);
+	ret = nvme_ns_ioctl(ns, cmd, argp, 0, file->f_mode);
 out_unlock:
 	srcu_read_unlock(&head->srcu, srcu_idx);
 	return ret;
@@ -946,7 +961,7 @@ static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp,
 	kref_get(&ns->kref);
 	up_read(&ctrl->namespaces_rwsem);
 
-	ret = nvme_user_cmd(ctrl, ns, argp, mode);
+	ret = nvme_user_cmd(ctrl, ns, argp, 0, mode);
 	nvme_put_ns(ns);
 	return ret;
 
@@ -963,7 +978,7 @@ long nvme_dev_ioctl(struct file *file, unsigned int cmd,
 
 	switch (cmd) {
 	case NVME_IOCTL_ADMIN_CMD:
-		return nvme_user_cmd(ctrl, NULL, argp, file->f_mode);
+		return nvme_user_cmd(ctrl, NULL, argp, 0, file->f_mode);
 	case NVME_IOCTL_ADMIN64_CMD:
 		return nvme_user_cmd64(ctrl, NULL, argp, 0, file->f_mode);
 	case NVME_IOCTL_IO_CMD:
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] nvme: remove __nvme_ioctl
  2023-01-08 16:50   ` [PATCH 1/3] nvme: remove __nvme_ioctl Christoph Hellwig
@ 2023-01-09  7:34     ` Chaitanya Kulkarni
  2023-01-12 13:20     ` Hannes Reinecke
  1 sibling, 0 replies; 13+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Kanchan Joshi, Sagi Grimberg, Keith Busch, linux-nvme,
	Chaitanya Kulkarni

On 1/8/23 08:50, Christoph Hellwig wrote:
> Open code __nvme_ioctl in the two callers to make future changes that
> pass down additional paramters in the ioctl path easier.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path
  2023-01-08 16:50   ` [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path Christoph Hellwig
@ 2023-01-09  7:39     ` Chaitanya Kulkarni
  2023-01-12 13:21     ` Hannes Reinecke
  1 sibling, 0 replies; 13+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:39 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Kanchan Joshi, Chaitanya Kulkarni, Sagi Grimberg, Keith Busch,
	linux-nvme

On 1/8/23 08:50, Christoph Hellwig wrote:
> To prepare for passing down more information, replace the boolean
> vec argument with a more extensible flags one.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions
  2023-01-08 16:50   ` [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions Christoph Hellwig
@ 2023-01-09  7:40     ` Chaitanya Kulkarni
  2023-01-12 13:23     ` Hannes Reinecke
  1 sibling, 0 replies; 13+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:40 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Kanchan Joshi, Chaitanya Kulkarni, Keith Busch, linux-nvme,
	Sagi Grimberg

On 1/8/23 08:50, Christoph Hellwig wrote:
> Passthrough commands can always access the entire device, and thus
> submitting them on partitions is an privelege escalation.
> 
> In hindsight we should have never allowed any passthrough commands on
> partitions, but it's probably too late to change that decision now.
> 
> Fixes: e4fbcf32c860 ("nvme: identify-namespace without CAP_SYS_ADMIN")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/nvme/host/ioctl.c | 47 ++++++++++++++++++++++++++-------------
>   1 file changed, 31 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index 999ebc1b700056..06f52db34be9bd 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -10,16 +10,24 @@
>   

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: don't allow unprivileged passthrough on partitions
  2023-01-08 16:50 ` don't allow unprivileged passthrough on partitions Christoph Hellwig
                     ` (2 preceding siblings ...)
  2023-01-08 16:50   ` [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions Christoph Hellwig
@ 2023-01-09 10:45   ` Kanchan Joshi
  2023-01-09 15:13   ` Keith Busch
  4 siblings, 0 replies; 13+ messages in thread
From: Kanchan Joshi @ 2023-01-09 10:45 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Keith Busch, Sagi Grimberg, Chaitanya Kulkarni, linux-nvme

[-- Attachment #1: Type: text/plain, Size: 215 bytes --]

On Sun, Jan 08, 2023 at 05:50:30PM +0100, Christoph Hellwig wrote:
>Hi all,
>
>this series fixes ensures that unprivileged passthrough can't be
>used on partitions.

Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: don't allow unprivileged passthrough on partitions
  2023-01-08 16:50 ` don't allow unprivileged passthrough on partitions Christoph Hellwig
                     ` (3 preceding siblings ...)
  2023-01-09 10:45   ` Kanchan Joshi
@ 2023-01-09 15:13   ` Keith Busch
  4 siblings, 0 replies; 13+ messages in thread
From: Keith Busch @ 2023-01-09 15:13 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Chaitanya Kulkarni, Kanchan Joshi, linux-nvme

Series looks good.

Reviewed-by: Keith Busch <kbusch@kernel.org>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] nvme: remove __nvme_ioctl
  2023-01-08 16:50   ` [PATCH 1/3] nvme: remove __nvme_ioctl Christoph Hellwig
  2023-01-09  7:34     ` Chaitanya Kulkarni
@ 2023-01-12 13:20     ` Hannes Reinecke
  1 sibling, 0 replies; 13+ messages in thread
From: Hannes Reinecke @ 2023-01-12 13:20 UTC (permalink / raw)
  To: linux-nvme

On 1/8/23 17:50, Christoph Hellwig wrote:
> Open code __nvme_ioctl in the two callers to make future changes that
> pass down additional paramters in the ioctl path easier.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/nvme/host/ioctl.c | 18 ++++++++----------
>   1 file changed, 8 insertions(+), 10 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path
  2023-01-08 16:50   ` [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path Christoph Hellwig
  2023-01-09  7:39     ` Chaitanya Kulkarni
@ 2023-01-12 13:21     ` Hannes Reinecke
  1 sibling, 0 replies; 13+ messages in thread
From: Hannes Reinecke @ 2023-01-12 13:21 UTC (permalink / raw)
  To: Christoph Hellwig, Keith Busch, Sagi Grimberg, Chaitanya Kulkarni
  Cc: Kanchan Joshi, linux-nvme

On 1/8/23 17:50, Christoph Hellwig wrote:
> To prepare for passing down more information, replace the boolean
> vec argument with a more extensible flags one.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/nvme/host/ioctl.c | 53 +++++++++++++++++++++------------------
>   1 file changed, 28 insertions(+), 25 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions
  2023-01-08 16:50   ` [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions Christoph Hellwig
  2023-01-09  7:40     ` Chaitanya Kulkarni
@ 2023-01-12 13:23     ` Hannes Reinecke
  2023-01-12 14:03       ` Christoph Hellwig
  1 sibling, 1 reply; 13+ messages in thread
From: Hannes Reinecke @ 2023-01-12 13:23 UTC (permalink / raw)
  To: Christoph Hellwig, Keith Busch, Sagi Grimberg, Chaitanya Kulkarni
  Cc: Kanchan Joshi, linux-nvme

On 1/8/23 17:50, Christoph Hellwig wrote:
> Passthrough commands can always access the entire device, and thus
> submitting them on partitions is an privelege escalation.
> 
> In hindsight we should have never allowed any passthrough commands on
> partitions, but it's probably too late to change that decision now.
> 
> Fixes: e4fbcf32c860 ("nvme: identify-namespace without CAP_SYS_ADMIN")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/nvme/host/ioctl.c | 47 ++++++++++++++++++++++++++-------------
>   1 file changed, 31 insertions(+), 16 deletions(-)
> 
Doesn't a similar argument hold for ctrl vs ns-specific commands?

Otherwise:

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions
  2023-01-12 13:23     ` Hannes Reinecke
@ 2023-01-12 14:03       ` Christoph Hellwig
  0 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-01-12 14:03 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, Keith Busch, Sagi Grimberg,
	Chaitanya Kulkarni, Kanchan Joshi, linux-nvme

On Thu, Jan 12, 2023 at 02:23:06PM +0100, Hannes Reinecke wrote:
> Doesn't a similar argument hold for ctrl vs ns-specific commands?

Can you phrase the argument?


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-01-12 14:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20230108165424epcas5p2b6d079dfcc8b1a91692f19729cc45b9a@epcas5p2.samsung.com>
2023-01-08 16:50 ` don't allow unprivileged passthrough on partitions Christoph Hellwig
2023-01-08 16:50   ` [PATCH 1/3] nvme: remove __nvme_ioctl Christoph Hellwig
2023-01-09  7:34     ` Chaitanya Kulkarni
2023-01-12 13:20     ` Hannes Reinecke
2023-01-08 16:50   ` [PATCH 2/3] nvme: replace the "bool vec" arguments with flags in the ioctl path Christoph Hellwig
2023-01-09  7:39     ` Chaitanya Kulkarni
2023-01-12 13:21     ` Hannes Reinecke
2023-01-08 16:50   ` [PATCH 3/3] nvme: don't allow unprivileged passthrough on partitions Christoph Hellwig
2023-01-09  7:40     ` Chaitanya Kulkarni
2023-01-12 13:23     ` Hannes Reinecke
2023-01-12 14:03       ` Christoph Hellwig
2023-01-09 10:45   ` Kanchan Joshi
2023-01-09 15:13   ` Keith Busch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.