Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4910619iob; Mon, 9 May 2022 04:41:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfjsteuJX+YTMaps1vDwgCvzqu2hfcxfwWFFXjxywhnLrsbCd9+DshGlqbhvPD4Qdpusr4 X-Received: by 2002:a17:902:7d89:b0:15e:e999:6b88 with SMTP id a9-20020a1709027d8900b0015ee9996b88mr15903301plm.98.1652096469626; Mon, 09 May 2022 04:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652096469; cv=none; d=google.com; s=arc-20160816; b=VOqfVsvaPsPaYfCIkuA8GE1BXdTi6MkJHFAwwBMbXdAwGgM5sFFNgFxjgR2pa1UK+l unKVs8vmFbxhMpztKpbcxj99gMGd6S8UXW/P9sXCRpso7yetngrySpcyOYKW/hLXWNnM 9piTO29Nn7vk4G1XOAdZoAbZnKwPOmPKFoof4WI8bJOCzTQXBN+KL5iJ5a5dLwebdjKj mFQMuYhbpiA6v0TiBmnaNds2P8BVVGuRPW6rrKmeAG16ihDNZPI2wpAU1zaM+FtHAS8K g7d00TiKjN+8WwHstumjbTNQzfYKHZpCM37trrLt2TIMI3rxoS8vLhZQzLER1+dRfuio XwoQ== 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=Zgd+3n/qlBTE26j3L8fKFM5bg9alGU9M6WFqa6Pw3Mc=; b=GFhUuFzpH9PYXqoQjgR6qQsTL8GI4B5ur2+oLykfblWu+4KBYiex292wQl1UvEnPkB 9ckdKtpsCGoxCh4oFM6JYhjcCCK/GabRs3Mn6UdYhFb9KHhoBK7NQCkqDO5doWYa+IwW snhKKrxlRfxtBnVAiFzmdkikO5fCcUzuJcKIGjTKIirwyDNJ1vNrbwh69TKCrPy0nKG4 S9h6WTmwXcDU3x8s74I4uA0U6ivkn0ACNePSaMCoX9otn/xnskM9X3fS1DvBC/UZc1/o 9XzxDSlbe2AbU57/hGTShhbJVBYYAyJIjKK6flFu1xNUN7dwyGdmzMZGdezlZ1C5sOAg 1XYA== 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=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ku10-20020a17090b218a00b001dc681e0241si18373227pjb.27.2022.05.09.04.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:41:09 -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=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2F2B620EE08; Mon, 9 May 2022 03:47:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbiEIKvg (ORCPT + 99 others); Mon, 9 May 2022 06:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiEIKuz (ORCPT ); Mon, 9 May 2022 06:50:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE52E2CC10B; Mon, 9 May 2022 03:46:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4A22660FD6; Mon, 9 May 2022 10:46:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CCB2C385B1; Mon, 9 May 2022 10:46:21 +0000 (UTC) Message-ID: <73a603a2-5e5e-1b45-8e19-ab0795027336@xs4all.nl> Date: Mon, 9 May 2022 12:46:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.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: 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 , Jiri Slaby , 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: Hans Verkuil In-Reply-To: <20220502160030.131168-3-cgzones@googlemail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 5/2/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/media/common/saa7146/saa7146_video.c | 2 +- > drivers/media/pci/bt8xx/bttv-driver.c | 3 +-- > drivers/media/pci/saa7134/saa7134-video.c | 3 +-- > drivers/media/platform/nxp/fsl-viu.c | 2 +- > drivers/media/test-drivers/vivid/vivid-vid-cap.c | 2 +- For the media drivers: Acked-by: Hans Verkuil Regards, Hans > drivers/net/caif/caif_serial.c | 2 +- > drivers/s390/block/dasd_eckd.c | 2 +- > 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; >