Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3048576pxu; Sun, 29 Nov 2020 13:19:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwknfd4pstzG6onbUjOlbjvSHLDwliPXj/LIdJc95//aZcjMjI0D3CTgL9F/+XFk0tDx7Z4 X-Received: by 2002:aa7:c3c3:: with SMTP id l3mr18063456edr.118.1606684760395; Sun, 29 Nov 2020 13:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606684760; cv=none; d=google.com; s=arc-20160816; b=bi9M3oiwKPNG8YDg8pOR+BoQvH4LEkGKMq2DbtyQO1dn8fqF7l3CZNLW4yYua0Fv0X C2HqOLVer8v4E9l+1MDg8pb38ClhonEiS94wIYKsbg/2OMm9DBEGOCUlg30bRqWskAsY Y7K4KL96GztMctLszagiHUryuatOM4q0bCKVcEtFH/vg6Z4yLsn7NcesIoooD+gNTrs+ mav5d2odsc7imr/7Se9z0m0JXtCNQaHbjPRaWDUjfYPxg9rvnUN4nxcN9NRXaWgKBIK7 3VdRTj7l9jmKvypGRxvUfYEBFT6H1EN/TTboET9mtZddza4GsqIHLBKWtpL8A+GKb1ZL tRDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KARikq5fok8CQyupjqW5E4Lvdp5Hq82S0KwqmZA7FGc=; b=NPwrYii4DryGOmVZjIPlPOlj8RaaDmww2BnqUztUT4dOkNaYDFw3sCTAli98CtnhIe xr7/2MOovlrgtrhExcvBNq92OCZC5utEaR1YfimP2jyYmXAWcgzau9KMwOdvopjZ2cUv 4Y+PgxVY0FaQAITmEqflZvbgoZ91KFNqhvO+vtX5aCfkeR3KiiRHeqLLDrno6vce6/MS SitOdIa2KfQtNXDx2xtS3Xvxx3jzGXwgtCiQnmRp/QcMC8SuAJY7w5Pue2utY8USBJk7 a+yAqzV/JOQzZk2IAnwpHuzy2SqF4brQHgg626VWmjir2H/H8qX2h4yleDHvR5CG0p8S aXEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si4660210edr.162.2020.11.29.13.18.56; Sun, 29 Nov 2020 13:19:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726669AbgK2VQa (ORCPT + 99 others); Sun, 29 Nov 2020 16:16:30 -0500 Received: from mail.hallyn.com ([178.63.66.53]:53500 "EHLO mail.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbgK2VQ3 (ORCPT ); Sun, 29 Nov 2020 16:16:29 -0500 Received: by mail.hallyn.com (Postfix, from userid 1001) id AE8171266; Sun, 29 Nov 2020 15:15:42 -0600 (CST) Date: Sun, 29 Nov 2020 15:15:42 -0600 From: "Serge E. Hallyn" To: James Morris Cc: "Serge E. Hallyn" , "Andrew G. Morgan" , lkml , =?iso-8859-1?Q?Herv=E9?= Guillemet , Casey Schaufler Subject: Re: [PATCH] fix namespaced fscaps when !CONFIG_SECURITY Message-ID: <20201129211542.GA5227@mail.hallyn.com> References: <20201117150856.GA12240@mail.hallyn.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, would you mind adding this to the security tree? (You can cherrypick from https://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux.git/commit/?h=2020-11-29/fix-nscaps ) thanks, -serge On Tue, Nov 17, 2020 at 08:09:59AM -0800, Andrew G. Morgan wrote: > Signed-off-by: Andrew G. Morgan > > > On Tue, Nov 17, 2020 at 7:09 AM Serge E. Hallyn wrote: > > > Namespaced file capabilities were introduced in 8db6c34f1dbc . > > When userspace reads an xattr for a namespaced capability, a > > virtualized representation of it is returned if the caller is > > in a user namespace owned by the capability's owning rootid. > > The function which performs this virtualization was not hooked > > up if CONFIG_SECURITY=n. Therefore in that case the original > > xattr was shown instead of the virtualized one. > > > > To test this using libcap-bin (*1), > > > > $ v=$(mktemp) > > $ unshare -Ur setcap cap_sys_admin-eip $v > > $ unshare -Ur setcap -v cap_sys_admin-eip $v > > /tmp/tmp.lSiIFRvt8Y: OK > > > > "setcap -v" verifies the values instead of setting them, and > > will check whether the rootid value is set. Therefore, with > > this bug un-fixed, and with CONFIG_SECURITY=n, setcap -v will > > fail: > > > > $ v=$(mktemp) > > $ unshare -Ur setcap cap_sys_admin=eip $v > > $ unshare -Ur setcap -v cap_sys_admin=eip $v > > nsowner[got=1000, want=0],/tmp/tmp.HHDiOOl9fY differs in [] > > > > Fix this bug by calling cap_inode_getsecurity() in > > security_inode_getsecurity() instead of returning > > -EOPNOTSUPP, when CONFIG_SECURITY=n. > > > > *1 - note, if libcap is too old for getcap to have the '-n' > > option, then use verify-caps instead. > > > > Signed-off-by: Serge Hallyn > > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1593431 > > Cc: Herv? Guillemet > > Cc: Andrew G. Morgan > > Cc: Casey Schaufler > > --- > > include/linux/security.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/include/linux/security.h b/include/linux/security.h > > index bc2725491560..39642626a707 100644 > > --- a/include/linux/security.h > > +++ b/include/linux/security.h > > @@ -869,7 +869,7 @@ static inline int security_inode_killpriv(struct > > dentry *dentry) > > > > static inline int security_inode_getsecurity(struct inode *inode, const > > char *name, void **buffer, bool alloc) > > { > > - return -EOPNOTSUPP; > > + return cap_inode_getsecurity(inode, name, buffer, alloc); > > } > > > > static inline int security_inode_setsecurity(struct inode *inode, const > > char *name, const void *value, size_t size, int flags) > > -- > > 2.25.1 > > > >