From patchwork Thu May 11 07:05:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "tianjia.zhang" X-Patchwork-Id: 13237543 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9E2DC7EE22 for ; Thu, 11 May 2023 07:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237410AbjEKHGQ (ORCPT ); Thu, 11 May 2023 03:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237200AbjEKHGJ (ORCPT ); Thu, 11 May 2023 03:06:09 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AAFA6E87; Thu, 11 May 2023 00:05:32 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0ViJb7g-_1683788728; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0ViJb7g-_1683788728) by smtp.aliyun-inc.com; Thu, 11 May 2023 15:05:29 +0800 From: Tianjia Zhang To: Serge Hallyn , Paul Moore , Stephen Smalley , Eric Paris , Frederick Lawler , Jens Axboe , Joseph Qi , linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianjia Zhang Subject: [PATCH 2/2] block: use block_admin_capable() for Persistent Reservations Date: Thu, 11 May 2023 15:05:20 +0800 Message-Id: <20230511070520.72939-3-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230511070520.72939-1-tianjia.zhang@linux.alibaba.com> References: <20230511070520.72939-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Use the newly introduced capability CAP_BLOCK_ADMIN for Persistent Reservations. Signed-off-by: Tianjia Zhang --- block/ioctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/ioctl.c b/block/ioctl.c index 9c5f637ff153..83af050eaa42 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -260,7 +260,7 @@ 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)) + if (!block_admin_capable()) return -EPERM; if (!ops || !ops->pr_register) return -EOPNOTSUPP; @@ -278,7 +278,7 @@ 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)) + if (!block_admin_capable()) return -EPERM; if (!ops || !ops->pr_reserve) return -EOPNOTSUPP; @@ -296,7 +296,7 @@ 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)) + if (!block_admin_capable()) return -EPERM; if (!ops || !ops->pr_release) return -EOPNOTSUPP; @@ -314,7 +314,7 @@ 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)) + if (!block_admin_capable()) return -EPERM; if (!ops || !ops->pr_preempt) return -EOPNOTSUPP; @@ -332,7 +332,7 @@ 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)) + if (!block_admin_capable()) return -EPERM; if (!ops || !ops->pr_clear) return -EOPNOTSUPP;