linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] allow blk-zoned ioctls without CAP_SYS_ADMIN
@ 2021-08-09  9:50 Niklas Cassel
  2021-08-09  9:50 ` [PATCH v4 1/2] blk-zoned: allow zone management send operations " Niklas Cassel
  2021-08-09  9:50 ` [PATCH v4 2/2] blk-zoned: allow BLKREPORTZONE " Niklas Cassel
  0 siblings, 2 replies; 6+ messages in thread
From: Niklas Cassel @ 2021-08-09  9:50 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal, Hannes Reinecke, Martin K. Petersen,
	Shaun Tancheff
  Cc: Damien Le Moal, Niklas Cassel, Jens Axboe, linux-block, linux-kernel

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

Allow the following blk-zoned ioctls: BLKREPORTZONE, BLKRESETZONE,
BLKOPENZONE, BLKCLOSEZONE, and BLKFINISHZONE to be performed without
CAP_SYS_ADMIN.

Neither read() nor write() requires CAP_SYS_ADMIN, and considering
the close relationship between read()/write() and these ioctls, there
is no reason to require CAP_SYS_ADMIN for these ioctls either.

Changes since v3:
-Picked up additional Reviewed-by tags.


Niklas Cassel (2):
  blk-zoned: allow zone management send operations without CAP_SYS_ADMIN
  blk-zoned: allow BLKREPORTZONE without CAP_SYS_ADMIN

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

-- 
2.31.1

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

* [PATCH v4 1/2] blk-zoned: allow zone management send operations without CAP_SYS_ADMIN
  2021-08-09  9:50 [PATCH v4 0/2] allow blk-zoned ioctls without CAP_SYS_ADMIN Niklas Cassel
@ 2021-08-09  9:50 ` Niklas Cassel
  2021-08-09  9:57   ` Johannes Thumshirn
  2021-08-09  9:50 ` [PATCH v4 2/2] blk-zoned: allow BLKREPORTZONE " Niklas Cassel
  1 sibling, 1 reply; 6+ messages in thread
From: Niklas Cassel @ 2021-08-09  9:50 UTC (permalink / raw)
  To: Jens Axboe, Hannes Reinecke, Martin K. Petersen, Shaun Tancheff,
	Damien Le Moal
  Cc: Damien Le Moal, Niklas Cassel, Aravind Ramesh, Adam Manzanares,
	Himanshu Madhani, stable, Jens Axboe, linux-block, linux-kernel

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>
Cc: stable@vger.kernel.org # v4.10+
---
Changes since v3:
-Picked up additional Reviewed-by tags.

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

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

* [PATCH v4 2/2] blk-zoned: allow BLKREPORTZONE without CAP_SYS_ADMIN
  2021-08-09  9:50 [PATCH v4 0/2] allow blk-zoned ioctls without CAP_SYS_ADMIN Niklas Cassel
  2021-08-09  9:50 ` [PATCH v4 1/2] blk-zoned: allow zone management send operations " Niklas Cassel
@ 2021-08-09  9:50 ` Niklas Cassel
  2021-08-09  9:58   ` Johannes Thumshirn
  1 sibling, 1 reply; 6+ messages in thread
From: Niklas Cassel @ 2021-08-09  9:50 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal, Hannes Reinecke, Shaun Tancheff,
	Martin K. Petersen
  Cc: Damien Le Moal, Niklas Cassel, Damien Le Moal, Aravind Ramesh,
	Adam Manzanares, Himanshu Madhani, stable, Jens Axboe,
	linux-block, linux-kernel

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

A user space process should not need the CAP_SYS_ADMIN capability set
in order to perform a BLKREPORTZONE ioctl.

Getting the zone report is required in order to get the write pointer.
Neither read() nor write() requires CAP_SYS_ADMIN, so it is reasonable
that a user space process that can read/write from/to the device, also
can get the write pointer. (Since e.g. writes have to be at the write
pointer.)

Fixes: 3ed05a987e0f ("blk-zoned: implement ioctls")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@dc.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>
Cc: stable@vger.kernel.org # v4.10+
---
Changes since v3:
-Picked up additional Reviewed-by tags.

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

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 8a60dbeb44be..1d0c76c18fc5 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -360,9 +360,6 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!blk_queue_is_zoned(q))
 		return -ENOTTY;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
 	if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
 		return -EFAULT;
 
-- 
2.31.1

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

* Re: [PATCH v4 1/2] blk-zoned: allow zone management send operations without CAP_SYS_ADMIN
  2021-08-09  9:50 ` [PATCH v4 1/2] blk-zoned: allow zone management send operations " Niklas Cassel
@ 2021-08-09  9:57   ` Johannes Thumshirn
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2021-08-09  9:57 UTC (permalink / raw)
  To: Niklas Cassel, Jens Axboe, Hannes Reinecke, Martin K. Petersen,
	Shaun Tancheff, Damien Le Moal
  Cc: Aravind Ramesh, Adam Manzanares, Himanshu Madhani, stable,
	Jens Axboe, linux-block, linux-kernel

On 09/08/2021 11:50, Niklas Cassel wrote:
> 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>
> Cc: stable@vger.kernel.org # v4.10+
> ---

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

* Re: [PATCH v4 2/2] blk-zoned: allow BLKREPORTZONE without CAP_SYS_ADMIN
  2021-08-09  9:50 ` [PATCH v4 2/2] blk-zoned: allow BLKREPORTZONE " Niklas Cassel
@ 2021-08-09  9:58   ` Johannes Thumshirn
  2021-08-09 10:04     ` Niklas Cassel
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Thumshirn @ 2021-08-09  9:58 UTC (permalink / raw)
  To: Niklas Cassel, Jens Axboe, Damien Le Moal, Hannes Reinecke,
	Shaun Tancheff, Martin K. Petersen
  Cc: Damien Le Moal, Aravind Ramesh, Adam Manzanares,
	Himanshu Madhani, stable, Jens Axboe, linux-block, linux-kernel

On 09/08/2021 11:50, Niklas Cassel wrote:
> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> A user space process should not need the CAP_SYS_ADMIN capability set
> in order to perform a BLKREPORTZONE ioctl.
> 
> Getting the zone report is required in order to get the write pointer.
> Neither read() nor write() requires CAP_SYS_ADMIN, so it is reasonable
> that a user space process that can read/write from/to the device, also
> can get the write pointer. (Since e.g. writes have to be at the write
> pointer.)
> 
> Fixes: 3ed05a987e0f ("blk-zoned: implement ioctls")
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> Reviewed-by: Damien Le Moal <damien.lemoal@dc.com>
Nit: Missing 'w'
> Reviewed-by: Aravind Ramesh <aravind.ramesh@wdc.com>
> Reviewed-by: Adam Manzanares <a.manzanares@samsung.com>
> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: stable@vger.kernel.org # v4.10+
> ---
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>


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

* Re: [PATCH v4 2/2] blk-zoned: allow BLKREPORTZONE without CAP_SYS_ADMIN
  2021-08-09  9:58   ` Johannes Thumshirn
@ 2021-08-09 10:04     ` Niklas Cassel
  0 siblings, 0 replies; 6+ messages in thread
From: Niklas Cassel @ 2021-08-09 10:04 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Jens Axboe, Damien Le Moal, Hannes Reinecke, Shaun Tancheff,
	Martin K. Petersen, Damien Le Moal, Aravind Ramesh,
	Adam Manzanares, Himanshu Madhani, stable, Jens Axboe,
	linux-block, linux-kernel

On Mon, Aug 09, 2021 at 09:58:17AM +0000, Johannes Thumshirn wrote:
> On 09/08/2021 11:50, Niklas Cassel wrote:
> > From: Niklas Cassel <niklas.cassel@wdc.com>
> > 
> > A user space process should not need the CAP_SYS_ADMIN capability set
> > in order to perform a BLKREPORTZONE ioctl.
> > 
> > Getting the zone report is required in order to get the write pointer.
> > Neither read() nor write() requires CAP_SYS_ADMIN, so it is reasonable
> > that a user space process that can read/write from/to the device, also
> > can get the write pointer. (Since e.g. writes have to be at the write
> > pointer.)
> > 
> > Fixes: 3ed05a987e0f ("blk-zoned: implement ioctls")
> > Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> > Reviewed-by: Damien Le Moal <damien.lemoal@dc.com>
> Nit: Missing 'w'

Seems like Damien's email had a typo in his original reply:

https://patchwork.kernel.org/project/linux-block/patch/20210614122303.154378-3-Niklas.Cassel@wdc.com/#24252237

Surprised that he doesn't have a shortcut to paste his Reviewed-by tag,
considering the amount of patches that he reviews :)

> > Reviewed-by: Aravind Ramesh <aravind.ramesh@wdc.com>
> > Reviewed-by: Adam Manzanares <a.manzanares@samsung.com>
> > Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
> > Cc: stable@vger.kernel.org # v4.10+
> > ---
> Looks good,
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> 

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

end of thread, other threads:[~2021-08-09 10:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  9:50 [PATCH v4 0/2] allow blk-zoned ioctls without CAP_SYS_ADMIN Niklas Cassel
2021-08-09  9:50 ` [PATCH v4 1/2] blk-zoned: allow zone management send operations " Niklas Cassel
2021-08-09  9:57   ` Johannes Thumshirn
2021-08-09  9:50 ` [PATCH v4 2/2] blk-zoned: allow BLKREPORTZONE " Niklas Cassel
2021-08-09  9:58   ` Johannes Thumshirn
2021-08-09 10:04     ` Niklas Cassel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).