Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp713149lqb; Fri, 15 Mar 2024 04:40:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGc/QGgw2bGD2j1ghOqs6AkwKHOwQCHsLYTjeEwtCldIEUteM/L+qMJK8Xfx28wtMSeQXGVa4F7UscIcD7qirCrif6+1BhI6rnL4sNUw== X-Google-Smtp-Source: AGHT+IES/GwtKfmh67PS4/ZCw/t49AIZStZMnrXCGaC363/AcVCpHBi+5ve5K1oRQgSobLmEcEwa X-Received: by 2002:a05:620a:17a4:b0:789:cfaf:c800 with SMTP id ay36-20020a05620a17a400b00789cfafc800mr8359917qkb.25.1710502833921; Fri, 15 Mar 2024 04:40:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710502833; cv=pass; d=google.com; s=arc-20160816; b=SJ8wYPnK13srQEg2zDX52CPhsmJsxrKetqPEGNdVttc3Qf3puROSLep4pgX7seMl8a +dF64Bf8GrNaRWui2aP2RZqHZvf+z0Rglv+6IM9OVgIicClHdbJRHR+cN7/E2QT9jLdr 9fnrpX245M+52AYraxraVxRbr5Q5NVQb5+sUPVGvjkpwSB9oc1n1lY9oB424klHy9ty/ KoCOz2tHwaKAsEK8hdPq8eH82ptjyar26XdFz0Ff5CoiuDttPHyQUbeWoRI7jh8k0QbW 7KisH27Vf5ePhJtMmUOal70zycxp10aTHlhXSZ1+SXWv0BY88+4hsdtVLBoeXUpHxjL3 hIgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ajSGsc6A/F/qkby1cV3DFijz3ujuoh7yFblhBSAWTk4=; fh=5gvDDnCZn0XgVdJfIU/kFb0Ode0Gdmxmisz0F0dRUn8=; b=0+bO//uMHfyxeJClxxEvxlMnurtzdEmIotNeyF6O3sRLYPz643qO0/bHAp11DCbeAH t4YLvw9TYLlRgfkMhG9rYO1WY17rFcyw4+jelNJSMfe4WpPQ32PKhyzVjuKRm9MCNnbe Rczqml2/xWLTEbnukgWD8m76tOWtad43xI9wPicrATVYL0rv90LgTnyje2fRWE08MySs uYT07NOQ7Og0AtEWKX3ZK2gPfs4m/HgdHqxpSoZhwAH/33qEPRQygEcpgHA88UF+nYCG uDhc3vAxF2E5CY/HOmgSymZjcQ+F6qVDnpKlBVEfBoYm2TW7kOEmFG/0BzAaAG26L0Ha /4Hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20230601 header.b=m+EyuCEe; arc=pass (i=1 spf=pass spfdomain=googlemail.com dkim=pass dkdomain=googlemail.com dmarc=pass fromdomain=googlemail.com); spf=pass (google.com: domain of linux-kernel+bounces-104354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104354-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j23-20020a37ef17000000b00787d6989706si3464036qkk.98.2024.03.15.04.40.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 04:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20230601 header.b=m+EyuCEe; arc=pass (i=1 spf=pass spfdomain=googlemail.com dkim=pass dkdomain=googlemail.com dmarc=pass fromdomain=googlemail.com); spf=pass (google.com: domain of linux-kernel+bounces-104354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104354-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 908E41C21866 for ; Fri, 15 Mar 2024 11:40:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DC6724B26; Fri, 15 Mar 2024 11:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="m+EyuCEe" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B59811C692; Fri, 15 Mar 2024 11:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710502745; cv=none; b=lhIN4Or1KuKN4RKS/+L4E2I8RzQwzLzMLYZPh1O7YjB7SJe0x+2Pg4eMxUbPdiGjzDkEracPC/u/aeAWhGxWyOhSWaYxkPfL77WDuWfMD1siKA3+zzU8NC6mn4MEZMqSMrYRJoTA2ab6WCmtAAjXYcVEO/O/waG4DJI1j7kiB08= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710502745; c=relaxed/simple; bh=e1y/a3hAt3iIY1eG/bhFWCCip3ImzDp68z3R3ZufW3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xwzu25MZ2ZjUIli76vBHaHNkUeXa7oMbHKbxFd8ku3r0kSdrLLp+D/l3HiJ16RWg3dkrLFgYwhK4RqoXAlDWyobuhO+rf9RIuCj8WJWooAgx8PAf5BiPeoS5FxJmNS2rM1MBg/66HaZicNuPpi1moaR3AV8j1Bylf+64+M2PYEk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=m+EyuCEe; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a3ddc13bbb3so562203166b.0; Fri, 15 Mar 2024 04:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1710502742; x=1711107542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ajSGsc6A/F/qkby1cV3DFijz3ujuoh7yFblhBSAWTk4=; b=m+EyuCEesIsDuGQ6AVn09GFl/Sc9Nd1IwniLlBRMSQlyFvpRQe/06nj77PnnEloORY ZSUZVXKOoAejW0/VB00UtZf6ZSbeD7uZzmqOzZV1T/1uIM3sB/aIuDjGDvyE6YnP4Fmr CBsKffMJAUEBZHNoPqPBsq+8XqN0JvTmBZrvp3biKpN+F9AxuvgpmCAIYK6+4pLBnXPH gpWTMbfeiTGUUiKu/sTJij2ePn5wtuqpfISjV/bRnlHOXgMKEpJV+Yj9eWkSExR6gmr8 Wqu6i3pvXzzEfNsZ1cHXYDlN7u55voEv/tYewWcx49jKZgN4M7rurZB9+xf8KufXt1di dkvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710502742; x=1711107542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ajSGsc6A/F/qkby1cV3DFijz3ujuoh7yFblhBSAWTk4=; b=m2i20SLJ95nNtHMNV1/ybL3sZmOpq+j7FDhPe2un2YG1+HKFT1hsqT/k2KGh1cx92t FKeVy+mv3Tf/KT1bGmI2nKVZrmeXWV9mgnD+gobrHBNY8ieS1nM3Xg7f7hwakku6kuL9 g7gKPZOUG874dQJxz/RW0FKLmCiQffDPgphsY2upx1/0KzxiGr4qin4Y8ZNDuwIGoXCZ pCYAUkAJn2YXS2OBCmWyEHG2H1DOnqF35AAGf4OJJTHDcyLMMzjaIWEiZJFoJrallF8E /062jBqZ+bYLQYlg8jrWjBQS5XV1rXeT/F7a/d3UCYLzObCK9k6gN6Vc7IEh9HNzssaz Gtlg== X-Forwarded-Encrypted: i=1; AJvYcCU/u5xN97DqJsbxo/nBXCIhGdoK1TTMq11OvhNMcT1+NhREQal9tXbhUtGsp2her+EIccgs8RFBhbeC7GtuongHLOcx5VYALuN7NUcqQLRecxRzPQDKlPQfqSfGfeFnE6x2+PlfUdhG3HwCDYZlOOwXgaCbDVGBCHqdBweNDkt6W2x6UYEh7yu9A6Np9B89NwftCbbMeQ== X-Gm-Message-State: AOJu0Yw30OxrMnn6dC7TIntAxALHSWajHgjtbL/snVeqf7ro73gHFDHq GuNDRrxxrDXLGjw5jSxqmoqawMJu3NzGbP2jMebzidmV1w336KcmuI0DRKaVjvUlcQ== X-Received: by 2002:a17:906:1501:b0:a45:d7fb:8423 with SMTP id b1-20020a170906150100b00a45d7fb8423mr7825935ejd.9.1710502741739; Fri, 15 Mar 2024 04:39:01 -0700 (PDT) Received: from ddev.DebianHome (dynamic-095-119-217-226.95.119.pool.telefonica.de. [95.119.217.226]) by smtp.gmail.com with ESMTPSA id fg3-20020a056402548300b005682f47aea7sm1610024edb.94.2024.03.15.04.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 04:39:01 -0700 (PDT) From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= To: linux-security-module@vger.kernel.org Cc: Alexander Gordeev , Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Mark Brown , Greg Kroah-Hartman , "Jiri Slaby (SUSE)" , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 05/10] drivers: use new capable_any functionality Date: Fri, 15 Mar 2024 12:37:26 +0100 Message-ID: <20240315113828.258005-5-cgzones@googlemail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240315113828.258005-1-cgzones@googlemail.com> References: <20240315113828.258005-1-cgzones@googlemail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the new added capable_any function in appropriate cases, where a task is required to have any of two capabilities. Reorder CAP_SYS_ADMIN last. Signed-off-by: Christian Göttsche Acked-by: Alexander Gordeev (s390 portion) --- v4: Additional usage in kfd_ioctl() v3: rename to capable_any() --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 3 +-- drivers/net/caif/caif_serial.c | 2 +- drivers/s390/block/dasd_eckd.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index dfa8c69532d4..8c7ebca01c17 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -3290,8 +3290,7 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) * more priviledged access. */ if (unlikely(ioctl->flags & KFD_IOC_FLAG_CHECKPOINT_RESTORE)) { - if (!capable(CAP_CHECKPOINT_RESTORE) && - !capable(CAP_SYS_ADMIN)) { + if (!capable_any(CAP_CHECKPOINT_RESTORE, CAP_SYS_ADMIN)) { retcode = -EACCES; goto err_i1; } diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index ed3a589def6b..e908b9ce57dc 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -326,7 +326,7 @@ static int ldisc_open(struct tty_struct *tty) /* No write no play */ if (tty->ops->write == NULL) return -EOPNOTSUPP; - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_TTY_CONFIG)) + if (!capable_any(CAP_SYS_TTY_CONFIG, CAP_SYS_ADMIN)) return -EPERM; /* release devices to avoid name collision */ diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 373c1a86c33e..8f9a5136306a 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -5384,7 +5384,7 @@ static int dasd_symm_io(struct dasd_device *device, void __user *argp) char psf0, psf1; int rc; - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) + if (!capable_any(CAP_SYS_RAWIO, CAP_SYS_ADMIN)) return -EACCES; psf0 = psf1 = 0; -- 2.43.0