Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4910374iob; Mon, 9 May 2022 04:40:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhZ9vNk8gEuJF26H/oTGzotDkGykMfi44cUVJg3K7VqKjG375lPu046WGnyUKnANWm9QQr X-Received: by 2002:a62:fb0e:0:b0:505:fd9e:9218 with SMTP id x14-20020a62fb0e000000b00505fd9e9218mr16032593pfm.78.1652096445722; Mon, 09 May 2022 04:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652096445; cv=none; d=google.com; s=arc-20160816; b=g1j/myicz5FKplFNQNZ7b0aMfPIoHBJG1BqMngmhRlJRJJ9wwhW5LbTCjAocFlPb6C rduCGJsrxvm4VD0ulkEiAGHzhZe0xdXy7quarbW5mz+LR8jyJo+wFpkALtP4kg0aivns 8tGIJGvApbLbb+2aSy2Ip678d/OjKy+tMynWU92YlsmnYe+XQ+sckDh2wsRDHVf8OHG1 wM0N2psSlvKrajaaDWbWdSx7hw7aPidWv77mSR7zPNwBSTtI+VGTB2C5QHa5VOvWyKZg THSReaBNmHJTOYdVv54y43cM7NCPsJ/OmW7bU/OchKWliquZ//fboUPDNtEHkB5NtH59 +TMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=/AsWycpf07jduXjzH2VNWrB+QTWZXkpPIzj9j/mTLnY=; b=YY33+oe63Kp5GcavLWHacuyBY0oAl88sgVQajDba6QzBOoWCzsp5diAv4cI7tfjnsm HNFwL2YBAuQVELjVutPvSza5NI2ddqjFc7PsQumD8zpg7fB51UpJTWhMgC+7oUi7ikv4 Y6vlhrCQIbrAfPz6WTAvkdaT1J8d5cEZMoDOy38QfwVsIEsg46BYGKGJscYck2W+pDba d6uDUcCdRWovKl561GWBYqQ80zceG7wIEC8VmthroyH/4uDxdxVEiK/FoogcFrei4C6k XqExcjZ1wSoZYl7iBBYgbBGBtziprIY7i51hQclYo740ib6YC5/Ny6UYL0iHwdkxdrel 7Dyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bf13-20020a656d0d000000b003aa5155f4e8si10304175pgb.128.2022.05.09.04.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:40:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3AC51FE3EA; Mon, 9 May 2022 03:46:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231451AbiEIKuI (ORCPT + 99 others); Mon, 9 May 2022 06:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbiEIKtu (ORCPT ); Mon, 9 May 2022 06:49:50 -0400 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DC0165D5F; Mon, 9 May 2022 03:44:13 -0700 (PDT) Received: by mail-wm1-f53.google.com with SMTP id n6-20020a05600c3b8600b0039492b44ce7so1027208wms.5; Mon, 09 May 2022 03:44:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=/AsWycpf07jduXjzH2VNWrB+QTWZXkpPIzj9j/mTLnY=; b=WGDzzNprLAPAUZdI9HQvEBLWWgqFG3Gadgv7ghlmlOVTukZlTZvmGp//DST9QwME5g HLY7/xUJwOCTUldW4z7g6bOcOIGNNFkd30NGr8xN4KLXdM6GBvqtaEuQoAni8cepVEV5 7WQc+tyZDEpYYgPma54VlV5a0iGHFG5DsMmysegbyVJVF59jV0xSfrpQ2nb9GCaiwPs7 AQMnDfbGfZ7IiC2a/irvNpxoNPdiTDV1DZSvtAVT7iz3/pDoSHmoaCB5LiVYeXUKf+Ok YP4NTC3fbzhqgVKOarTh14OjQROOYXzu//314z841oM+4g0+rMD68w4BU2GCfWo1mz0d Iwrg== X-Gm-Message-State: AOAM5301iRr2GATQToqmHjJFu2ClevfbjrTFRwtRB3w8poCd/sH2lkay yjd3MAEsnmavQRhLknQK2GM= X-Received: by 2002:a05:600c:26d2:b0:393:fb8c:dc31 with SMTP id 18-20020a05600c26d200b00393fb8cdc31mr22167324wmv.129.1652093052075; Mon, 09 May 2022 03:44:12 -0700 (PDT) Received: from [192.168.1.49] (185-219-167-24-static.vivo.cz. [185.219.167.24]) by smtp.gmail.com with ESMTPSA id k21-20020adfb355000000b0020c5253d905sm13727381wrd.81.2022.05.09.03.44.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 May 2022 03:44:11 -0700 (PDT) Message-ID: <09374557-8c8d-1925-340c-784f29630ec5@kernel.org> Date: Mon, 9 May 2022 12:44:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v2 4/8] drivers: use new capable_or functionality Content-Language: en-US To: =?UTF-8?Q?Christian_G=c3=b6ttsche?= , selinux@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Serge Hallyn , Arnd Bergmann , Zhen Lei , Ondrej Zary , David Yang , Laurent Pinchart , Colin Ian King , Yang Guang , Julia Lawall , Greg Kroah-Hartman , Du Cheng , Sebastian Andrzej Siewior , Pavel Skripkin , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-security-module@vger.kernel.org References: <20220217145003.78982-2-cgzones@googlemail.com> <20220502160030.131168-1-cgzones@googlemail.com> <20220502160030.131168-3-cgzones@googlemail.com> From: Jiri Slaby In-Reply-To: <20220502160030.131168-3-cgzones@googlemail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02. 05. 22, 18:00, Christian Göttsche wrote: > Use the new added capable_or 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 > --- > drivers/net/caif/caif_serial.c | 2 +- For the above: Reviewed-by: Jiri Slaby > 7 files changed, 7 insertions(+), 9 deletions(-) > > diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c > index 66215d9106a4..5eabc2e77cc2 100644 > --- a/drivers/media/common/saa7146/saa7146_video.c > +++ b/drivers/media/common/saa7146/saa7146_video.c > @@ -470,7 +470,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, const struct v4l2_framebuf > > DEB_EE("VIDIOC_S_FBUF\n"); > > - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) > + if (!capable_or(CAP_SYS_RAWIO, CAP_SYS_ADMIN)) > return -EPERM; > > /* check args */ > diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c > index 5ca3d0cc653a..4143f380d44d 100644 > --- a/drivers/media/pci/bt8xx/bttv-driver.c > +++ b/drivers/media/pci/bt8xx/bttv-driver.c > @@ -2569,8 +2569,7 @@ static int bttv_s_fbuf(struct file *file, void *f, > const struct bttv_format *fmt; > int retval; > > - if (!capable(CAP_SYS_ADMIN) && > - !capable(CAP_SYS_RAWIO)) > + if (!capable_or(CAP_SYS_RAWIO, CAP_SYS_ADMIN)) > return -EPERM; > > /* check args */ > diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c > index 48543ad3d595..684208ebfdbd 100644 > --- a/drivers/media/pci/saa7134/saa7134-video.c > +++ b/drivers/media/pci/saa7134/saa7134-video.c > @@ -1798,8 +1798,7 @@ static int saa7134_s_fbuf(struct file *file, void *f, > struct saa7134_dev *dev = video_drvdata(file); > struct saa7134_format *fmt; > > - if (!capable(CAP_SYS_ADMIN) && > - !capable(CAP_SYS_RAWIO)) > + if (!capable_or(CAP_SYS_RAWIO, CAP_SYS_ADMIN)) > return -EPERM; > > /* check args */ > diff --git a/drivers/media/platform/nxp/fsl-viu.c b/drivers/media/platform/nxp/fsl-viu.c > index afc96f6db2a1..c5ed4c4a1587 100644 > --- a/drivers/media/platform/nxp/fsl-viu.c > +++ b/drivers/media/platform/nxp/fsl-viu.c > @@ -803,7 +803,7 @@ static int vidioc_s_fbuf(struct file *file, void *priv, const struct v4l2_frameb > const struct v4l2_framebuffer *fb = arg; > struct viu_fmt *fmt; > > - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) > + if (!capable_or(CAP_SYS_RAWIO, CAP_SYS_ADMIN)) > return -EPERM; > > /* check args */ > diff --git a/drivers/media/test-drivers/vivid/vivid-vid-cap.c b/drivers/media/test-drivers/vivid/vivid-vid-cap.c > index b9caa4b26209..a0cfcf6c22c4 100644 > --- a/drivers/media/test-drivers/vivid/vivid-vid-cap.c > +++ b/drivers/media/test-drivers/vivid/vivid-vid-cap.c > @@ -1253,7 +1253,7 @@ int vivid_vid_cap_s_fbuf(struct file *file, void *fh, > if (dev->multiplanar) > return -ENOTTY; > > - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) > + if (!capable_or(CAP_SYS_RAWIO, CAP_SYS_ADMIN)) > return -EPERM; > > if (dev->overlay_cap_owner) > diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c > index 688075859ae4..f17b618d8858 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_or(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 8410a25a65c1..9b5d22dd3e7b 100644 > --- a/drivers/s390/block/dasd_eckd.c > +++ b/drivers/s390/block/dasd_eckd.c > @@ -5319,7 +5319,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_or(CAP_SYS_RAWIO, CAP_SYS_ADMIN)) > return -EACCES; > psf0 = psf1 = 0; > -- js suse labs