All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: Jens Axboe <axboe@kernel.dk>, Hannes Reinecke <hare@suse.com>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Shaun Tancheff <shaun@tancheff.com>
Cc: Damien Le Moal <Damien.LeMoal@wdc.com>,
	Niklas Cassel <Niklas.Cassel@wdc.com>,
	Aravind Ramesh <Aravind.Ramesh@wdc.com>,
	Adam Manzanares <a.manzanares@samsung.com>,
	Himanshu Madhani <himanshu.madhani@oracle.com>,
	Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	Jens Axboe <axboe@fb.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH v5 1/2] blk-zoned: allow zone management send operations without CAP_SYS_ADMIN
Date: Wed, 11 Aug 2021 11:05:18 +0000	[thread overview]
Message-ID: <20210811110505.29649-2-Niklas.Cassel@wdc.com> (raw)
In-Reply-To: <20210811110505.29649-1-Niklas.Cassel@wdc.com>

From: Niklas Cassel <niklas.cassel@wdc.com>

Zone management send operations (BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE
and BLKFINISHZONE) should be allowed under the same permissions as write().
(write() does not require CAP_SYS_ADMIN).

Additionally, other ioctls like BLKSECDISCARD and BLKZEROOUT only check if
the fd was successfully opened with FMODE_WRITE.
(They do not require CAP_SYS_ADMIN).

Currently, zone management send operations require both CAP_SYS_ADMIN
and that the fd was successfully opened with FMODE_WRITE.

Remove the CAP_SYS_ADMIN requirement, so that zone management send
operations match the access control requirement of write(), BLKSECDISCARD
and BLKZEROOUT.

Fixes: 3ed05a987e0f ("blk-zoned: implement ioctls")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Aravind Ramesh <aravind.ramesh@wdc.com>
Reviewed-by: Adam Manzanares <a.manzanares@samsung.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: stable@vger.kernel.org # v4.10+
---
Changes since v4:
-Picked up additional Reviewed-by tag.

Note to backporter:
Function was added as blkdev_reset_zones_ioctl() in v4.10.
Function was renamed to blkdev_zone_mgmt_ioctl() in v5.5.
The patch is valid both before and after the function rename.

 block/blk-zoned.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 86fce751bb17..8a60dbeb44be 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -421,9 +421,6 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!blk_queue_is_zoned(q))
 		return -ENOTTY;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
 	if (!(mode & FMODE_WRITE))
 		return -EBADF;
 
-- 
2.31.1

  reply	other threads:[~2021-08-11 11:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 11:05 [PATCH v5 0/2] allow blk-zoned ioctls without CAP_SYS_ADMIN Niklas Cassel
2021-08-11 11:05 ` Niklas Cassel [this message]
2021-08-11 11:05 ` [PATCH v5 2/2] blk-zoned: allow BLKREPORTZONE " Niklas Cassel
2021-08-24 16:13 ` [PATCH v5 0/2] allow blk-zoned ioctls " Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210811110505.29649-2-Niklas.Cassel@wdc.com \
    --to=niklas.cassel@wdc.com \
    --cc=Aravind.Ramesh@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=a.manzanares@samsung.com \
    --cc=axboe@fb.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.com \
    --cc=himanshu.madhani@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=shaun@tancheff.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.