2021-08-09 10:24:24

by Niklas Cassel

[permalink] [raw]
Subject: [PATCH v4 1/2] blk-zoned: allow zone management send operations without CAP_SYS_ADMIN

From: Niklas Cassel <[email protected]>

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 <[email protected]>
Reviewed-by: Damien Le Moal <[email protected]>
Reviewed-by: Aravind Ramesh <[email protected]>
Reviewed-by: Adam Manzanares <[email protected]>
Reviewed-by: Himanshu Madhani <[email protected]>
Cc: [email protected] # 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


2021-08-09 14:00:42

by Johannes Thumshirn

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] blk-zoned: allow zone management send operations without CAP_SYS_ADMIN

On 09/08/2021 11:50, Niklas Cassel wrote:
> From: Niklas Cassel <[email protected]>
>
> 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 <[email protected]>
> Reviewed-by: Damien Le Moal <[email protected]>
> Reviewed-by: Aravind Ramesh <[email protected]>
> Reviewed-by: Adam Manzanares <[email protected]>
> Reviewed-by: Himanshu Madhani <[email protected]>
> Cc: [email protected] # v4.10+
> ---

Looks good,
Reviewed-by: Johannes Thumshirn <[email protected]>