public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: axboe@kernel.dk, hch@lst.de, linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, tianjia.zhang@linux.alibaba.com,
	xiang@kernel.org, casey@schaufler-ca.com
Subject: [RFC] block: relax permission for Persistent Reservations ioctl
Date: Fri,  9 Jun 2023 18:21:22 +0800	[thread overview]
Message-ID: <20230609102122.118800-1-jefflexu@linux.alibaba.com> (raw)

When the shared storage is accessed from containers [1], it's not
recommended to grant CAP_SYS_ADMIN to containers for access to
Persistent Reservations in risk of container escape.

Remove the extra CAP_SYS_ADMIN permission constraint for Persistent
Reservations ioctl which shall do no harm [2].

[1] https://lore.kernel.org/linux-block/345a7cdc-e55b-7aaa-43d4-59b3f911ef18@linux.alibaba.com/
[2] https://lore.kernel.org/linux-block/ZGxaxnOeadVwb2gR@infradead.org/

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
I also noticed that the extra CAP_SYS_ADMIN permission constraint is not
added until v4 [*] of original pull request for Persistent Reservation
API.

[*] https://lore.kernel.org/all/1444911052-9423-1-git-send-email-hch@lst.de/
---
 block/ioctl.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index 9c5f637ff153..46c9ac43bbf8 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -260,8 +260,6 @@ static int blkdev_pr_register(struct block_device *bdev,
 	const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops;
 	struct pr_registration reg;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
 	if (!ops || !ops->pr_register)
 		return -EOPNOTSUPP;
 	if (copy_from_user(&reg, arg, sizeof(reg)))
@@ -278,8 +276,6 @@ static int blkdev_pr_reserve(struct block_device *bdev,
 	const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops;
 	struct pr_reservation rsv;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
 	if (!ops || !ops->pr_reserve)
 		return -EOPNOTSUPP;
 	if (copy_from_user(&rsv, arg, sizeof(rsv)))
@@ -296,8 +292,6 @@ static int blkdev_pr_release(struct block_device *bdev,
 	const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops;
 	struct pr_reservation rsv;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
 	if (!ops || !ops->pr_release)
 		return -EOPNOTSUPP;
 	if (copy_from_user(&rsv, arg, sizeof(rsv)))
@@ -314,8 +308,6 @@ static int blkdev_pr_preempt(struct block_device *bdev,
 	const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops;
 	struct pr_preempt p;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
 	if (!ops || !ops->pr_preempt)
 		return -EOPNOTSUPP;
 	if (copy_from_user(&p, arg, sizeof(p)))
@@ -332,8 +324,6 @@ static int blkdev_pr_clear(struct block_device *bdev,
 	const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops;
 	struct pr_clear c;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
 	if (!ops || !ops->pr_clear)
 		return -EOPNOTSUPP;
 	if (copy_from_user(&c, arg, sizeof(c)))
-- 
2.19.1.6.gb485710b


             reply	other threads:[~2023-06-09 10:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 10:21 Jingbo Xu [this message]
2023-06-10  6:06 ` [RFC] block: relax permission for Persistent Reservations ioctl Christoph Hellwig
2023-06-10  8:12   ` Jingbo Xu

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=20230609102122.118800-1-jefflexu@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=axboe@kernel.dk \
    --cc=casey@schaufler-ca.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tianjia.zhang@linux.alibaba.com \
    --cc=xiang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox