From: Niklas Cassel <[email protected]>
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 v2:
-Drop the FMODE_READ check from patch 2/2.
Right now it is possible to open() the device with O_WRONLY
and get the zone report from that fd. Therefore adding a
FMODE_READ check on BLKREPORTZONE would break existing applications.
Instead, just remove the existing CAP_SYS_ADMIN check.
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
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]>
Cc: [email protected] # v4.10+
---
Changes since v2:
-None
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 250cb76ee615..0789e6e9f7db 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -349,9 +349,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
From: Niklas Cassel <[email protected]>
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 <[email protected]>
Cc: [email protected] # v4.10+
---
Changes since v2:
-Drop the FMODE_READ check. Right now it is possible to open() the device with
O_WRONLY and get the zone report from that fd. Therefore adding a FMODE_READ
check on BLKREPORTZONE would break existing applications. Instead, just remove
the existing CAP_SYS_ADMIN check.
block/blk-zoned.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 0789e6e9f7db..457eceabed2e 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -288,9 +288,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
On 2021/06/14 21:23, Niklas Cassel wrote:
> From: Niklas Cassel <[email protected]>
>
> 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 <[email protected]>
> Cc: [email protected] # v4.10+
> ---
> Changes since v2:
> -Drop the FMODE_READ check. Right now it is possible to open() the device with
> O_WRONLY and get the zone report from that fd. Therefore adding a FMODE_READ
> check on BLKREPORTZONE would break existing applications. Instead, just remove
> the existing CAP_SYS_ADMIN check.
>
> block/blk-zoned.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 0789e6e9f7db..457eceabed2e 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -288,9 +288,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;
>
>
Looks good.
Reviewed-by: Damien Le Moal <[email protected]>
--
Damien Le Moal
Western Digital Research
> -----Original Message-----
> From: Niklas Cassel <[email protected]>
> Sent: Monday, June 14, 2021 5:53 PM
> To: Jens Axboe <[email protected]>; Damien Le Moal <[email protected]>;
> Shaun Tancheff <[email protected]>; Martin K. Petersen
> <[email protected]>; Hannes Reinecke <[email protected]>
> Cc: Damien Le Moal <[email protected]>; Niklas Cassel
> <[email protected]>; [email protected]; Jens Axboe <[email protected]>;
> [email protected]; [email protected]
> Subject: [PATCH v3 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]>
> Cc: [email protected] # v4.10+
> ---
> Changes since v2:
> -None
>
> 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
> 250cb76ee615..0789e6e9f7db 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -349,9 +349,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
Looks good,
Reviewed-by: Aravind Ramesh <[email protected]>
> -----Original Message-----
> From: Niklas Cassel <[email protected]>
> Sent: Monday, June 14, 2021 5:53 PM
> To: Jens Axboe <[email protected]>; Hannes Reinecke <[email protected]>; Martin K.
> Petersen <[email protected]>; Damien Le Moal
> <[email protected]>; Shaun Tancheff <[email protected]>
> Cc: Damien Le Moal <[email protected]>; Niklas Cassel
> <[email protected]>; [email protected]; Jens Axboe <[email protected]>;
> [email protected]; [email protected]
> Subject: [PATCH v3 2/2] blk-zoned: allow BLKREPORTZONE without
> CAP_SYS_ADMIN
>
> From: Niklas Cassel <[email protected]>
>
> 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 <[email protected]>
> Cc: [email protected] # v4.10+
> ---
> Changes since v2:
> -Drop the FMODE_READ check. Right now it is possible to open() the device with
> O_WRONLY and get the zone report from that fd. Therefore adding a FMODE_READ
> check on BLKREPORTZONE would break existing applications. Instead, just remove
> the existing CAP_SYS_ADMIN check.
>
> block/blk-zoned.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c index
> 0789e6e9f7db..457eceabed2e 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -288,9 +288,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
Looks good,
Reviewed-by: Aravind Ramesh <[email protected]>
On Mon, Jun 14, 2021 at 12:23:21PM +0000, Niklas Cassel wrote:
> From: Niklas Cassel <[email protected]>
>
> 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 <[email protected]>
> Cc: [email protected] # v4.10+
> ---
> Changes since v2:
> -Drop the FMODE_READ check. Right now it is possible to open() the device with
> O_WRONLY and get the zone report from that fd. Therefore adding a FMODE_READ
> check on BLKREPORTZONE would break existing applications. Instead, just remove
> the existing CAP_SYS_ADMIN check.
>
> block/blk-zoned.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 0789e6e9f7db..457eceabed2e 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -288,9 +288,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
LGTM
Reviewed-by: Adam Manzanares <[email protected]>
On Mon, Jun 14, 2021 at 12:23:20PM +0000, 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]>
> Cc: [email protected] # v4.10+
> ---
> Changes since v2:
> -None
>
> 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 250cb76ee615..0789e6e9f7db 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -349,9 +349,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
LGTM
Reviewed-by: Adam Manzanares <[email protected]>
On 6/14/21 7:23 AM, Niklas Cassel wrote:
> From: Niklas Cassel <[email protected]>
>
> 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 <[email protected]>
> Cc: [email protected] # v4.10+
> ---
> Changes since v2:
> -Drop the FMODE_READ check. Right now it is possible to open() the device with
> O_WRONLY and get the zone report from that fd. Therefore adding a FMODE_READ
> check on BLKREPORTZONE would break existing applications. Instead, just remove
> the existing CAP_SYS_ADMIN check.
>
> block/blk-zoned.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 0789e6e9f7db..457eceabed2e 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -288,9 +288,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;
>
>
Looks Good.
Reviewed-by: Himanshu Madhani <[email protected]>
--
Himanshu Madhani Oracle Linux Engineering
On 6/14/21 7:23 AM, 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]>
> Cc: [email protected] # v4.10+
> ---
> Changes since v2:
> -None
>
> 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 250cb76ee615..0789e6e9f7db 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -349,9 +349,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;
>
>
Looks Good.
Reviewed-by: Himanshu Madhani <[email protected]>
--
Himanshu Madhani Oracle Linux Engineering
On Mon, Jun 14, 2021 at 12:23:19PM +0000, Niklas Cassel wrote:
> From: Niklas Cassel <[email protected]>
>
> 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 v2:
> -Drop the FMODE_READ check from patch 2/2.
> Right now it is possible to open() the device with O_WRONLY
> and get the zone report from that fd. Therefore adding a
> FMODE_READ check on BLKREPORTZONE would break existing applications.
> Instead, just remove the existing CAP_SYS_ADMIN check.
>
>
> 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
Hello Jens,
A gentle ping on this series.
I think it has sufficient Reviewed-by tags by now.
Kind regards,
Niklas
On Mon, Jun 28, 2021 at 09:20:15AM +0200, Niklas Cassel wrote:
> On Mon, Jun 14, 2021 at 12:23:19PM +0000, Niklas Cassel wrote:
> > From: Niklas Cassel <[email protected]>
> >
> > 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 v2:
> > -Drop the FMODE_READ check from patch 2/2.
> > Right now it is possible to open() the device with O_WRONLY
> > and get the zone report from that fd. Therefore adding a
> > FMODE_READ check on BLKREPORTZONE would break existing applications.
> > Instead, just remove the existing CAP_SYS_ADMIN check.
> >
> >
> > 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
>
> Hello Jens,
>
>
> A gentle ping on this series.
>
> I think it has sufficient Reviewed-by tags by now.
>
>
> Kind regards,
> Niklas
Hello again Jens,
any chance of this series being picked up?
Kind regards,
Niklas
> -----Original Message-----
> From: Niklas Cassel <[email protected]>
> Sent: Monday, July 5, 2021 4:57 PM
> To: Jens Axboe <[email protected]>; Jens Axboe <[email protected]>
> Cc: [email protected]; [email protected]
> Subject: Re: [PATCH v3 0/2] allow blk-zoned ioctls without CAP_SYS_ADMIN
>
> On Mon, Jun 28, 2021 at 09:20:15AM +0200, Niklas Cassel wrote:
> > On Mon, Jun 14, 2021 at 12:23:19PM +0000, Niklas Cassel wrote:
> > > From: Niklas Cassel <[email protected]>
> > >
> > > 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 v2:
> > > -Drop the FMODE_READ check from patch 2/2.
> > > Right now it is possible to open() the device with O_WRONLY and get
> > > the zone report from that fd. Therefore adding a FMODE_READ check on
> > > BLKREPORTZONE would break existing applications.
> > > Instead, just remove the existing CAP_SYS_ADMIN check.
> > >
> > >
> > > 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
> >
> > Hello Jens,
> >
> >
> > A gentle ping on this series.
> >
> > I think it has sufficient Reviewed-by tags by now.
> >
> >
> > Kind regards,
> > Niklas
>
> Hello again Jens,
>
>
> any chance of this series being picked up?
>
Hello Jens,
Gentle ping.
Could you please take a look at this series ?
Thanks,
Aravind
>
> Kind regards,
> Niklas