From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B241C433DF for ; Wed, 3 Jun 2020 17:01:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AB3920772 for ; Wed, 3 Jun 2020 17:01:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aTM3zxQd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725955AbgFCRBk (ORCPT ); Wed, 3 Jun 2020 13:01:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbgFCRBj (ORCPT ); Wed, 3 Jun 2020 13:01:39 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E06C08C5C0; Wed, 3 Jun 2020 10:01:39 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id a25so3680186ljp.3; Wed, 03 Jun 2020 10:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2iLycb4I4u+ClXUUA0CCDPb6E6bGBrDChBPF7DQKh5s=; b=aTM3zxQdEXzyvTbG2wnsmyG5Ljh4kC5rX2FcLRM6yHZ9CsgexrRB/bG1xtfJfa65A9 tsuDK3j0xyJTbGyH04PSRBc940UT0MSX3j3Xe+ctCJQMgKojjCOxd1XLmqH5ScZEks84 m4YCGcEeD9yUDlJ47GdTrkDrj2a8lmTVqNf9eP4QeJb6pOjR64QQILWyFFVmk3gNQgik qCJJ0inXRDzPrrokm1ZjCjdg/Ve/bUmhUKBdeHV60tsuFclZjzehk+uWop6vHPnRhhLT hpu4HnylpXg3otqK3GBX0ovRt295MjpmsFRrfrwoX3e67peU3xc+oCRxmQ83jwZ1y6EB 4Q+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2iLycb4I4u+ClXUUA0CCDPb6E6bGBrDChBPF7DQKh5s=; b=mA0SNDny3lSdU5ZshxMmdcKkI7XRczGS87YqrgZHa8CbQJd5AI3l20UO1URCN6DX+n 3lHoGoEDT6bUusbF72AsiDww9LcE9xkeDX0AZlrWrJBNdaujiknZRuUGPAIKVhFqsIel mvSWD337IaL2uDqyPvlFnYFIKLMJmOp0b8VDxVc6QnHtwwdrFIFAUUHfSmIn+ZnSpS/A ofkyWOhq+f2xiBpJ/LwYHBNGE2/m4kkpBq5savpNiM6irp3xbRCMFjxmObwV3EJxrKxg 69nDbZjEpfkZ/Ph+RwCZ8yx12DLrTy+Vj29ujmXtxA7BSgcZ7gjLsICx38r41y2axcai JRyQ== X-Gm-Message-State: AOAM532D29PgTYaRQMv8BYcWVDd2evlAyUawt29V7eTBNukn9RJxB1kf JEgcPLPMFHDoVAyDgy+5B7g= X-Google-Smtp-Source: ABdhPJz9gyMboago8Er/iKySN0pf2TCLhXajvZU/DCrvcaHiJNcLnfsThNWvM3P5mHq0O1RvGu2jcg== X-Received: by 2002:a2e:9816:: with SMTP id a22mr87688ljj.129.1591203697862; Wed, 03 Jun 2020 10:01:37 -0700 (PDT) Received: from grain.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id b15sm784577lfa.74.2020.06.03.10.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:01:36 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id F2B391A0089; Wed, 3 Jun 2020 20:01:35 +0300 (MSK) Date: Wed, 3 Jun 2020 20:01:35 +0300 From: Cyrill Gorcunov To: Adrian Reber Cc: Christian Brauner , Eric Biederman , Pavel Emelyanov , Oleg Nesterov , Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , Nicolas Viennot , =?utf-8?B?TWljaGHFgiBDxYJhcGnFhHNraQ==?= , Kamil Yurtsever , Dirk Petersen , Christine Flood , Casey Schaufler , Mike Rapoport , Radostin Stoyanov , Serge Hallyn , Stephen Smalley , Sargun Dhillon , Arnd Bergmann , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, Eric Paris , Jann Horn , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 1/3] capabilities: Introduce CAP_CHECKPOINT_RESTORE Message-ID: <20200603170135.GD568636@grain> References: <20200603162328.854164-1-areber@redhat.com> <20200603162328.854164-2-areber@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200603162328.854164-2-areber@redhat.com> User-Agent: Mutt/1.13.4 (2020-02-15) Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org On Wed, Jun 03, 2020 at 06:23:26PM +0200, Adrian Reber wrote: ... > > /* > - * Only allow CAP_SYS_ADMIN to follow the links, due to concerns about how the > - * symlinks may be used to bypass permissions on ancestor directories in the > - * path to the file in question. > + * Only allow CAP_SYS_ADMIN and CAP_CHECKPOINT_RESTORE to follow the links, due > + * to concerns about how the symlinks may be used to bypass permissions on > + * ancestor directories in the path to the file in question. > */ > static const char * > proc_map_files_get_link(struct dentry *dentry, > struct inode *inode, > struct delayed_call *done) > { > - if (!capable(CAP_SYS_ADMIN)) > + if (!(capable(CAP_SYS_ADMIN) || capable(CAP_CHECKPOINT_RESTORE))) > return ERR_PTR(-EPERM); You know, I'm still not sure if we need this capable() check at all since we have proc_fd_access_allowed() called but anyway can we please make this if() condition more explicit if (!capable(CAP_SYS_ADMIN) && !capable(CAP_CHECKPOINT_RESTORE)) return ERR_PTR(-EPERM); though I won't insist. And I'll reread the series a bit later once I've some spare time to.