Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4134156pxu; Mon, 30 Nov 2020 19:03:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9UDKi0P/sU7PlVTI+A/dHw3JZLzUuNMBd1LGD96B39+JDMj1k1iUgHO/PhSt4Al+u23RZ X-Received: by 2002:a17:906:614:: with SMTP id s20mr1011744ejb.202.1606791801399; Mon, 30 Nov 2020 19:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606791801; cv=none; d=google.com; s=arc-20160816; b=b21hOcXpXSRKKeHGzO47ZtBX5KXZrZ4d7FnEgGvCUTAzRQli74FEn6G/DeB9F5h3Jt parYLntB2ezi0V8Oj2mvIn4EpsKVN5Bto3I4BYVzLV+alHb0ajgyJjO4AVUcDRW3tL1U V/IaUCtuI+ElpV6t2au0YMtRUy4uQa3+T8kELnxN3s9Gm3HGoyz1cG9vY0O/NaIOv117 /q4JfJPXleizakMCjRzGZxofeD437pDvKQNxeQp1cpKS627UNQtBuVib7Y7N7725j+3m p8bedtm5jn2Did86j2Lv0l9KGqEopFiKUQvHRuXp0RBcqdiQFhMx4qTEW4vbe4e8bQWU bEMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=5tz552tRgwhvZhAblR3xiAcY1eXbgFJtiAOQxhnHdkE=; b=rLIhuKTd/+DrSLPG7p5NHjQWQPxGwUiHf0J+fjtxleFibpWH8cBDILVLtuPLWToxWf 20VMx48xsuj+CXfKBtFf3lBD6I3yn3VTK3wG0PZTnIA+icivibQNsWM+OmPgBMuMpeDW g+Qo6XCerBpSNXa6Kxryr2lC1vuUjfm0Zw6e3pttwk4r/jLiuVwjAnFZYrHHSxfSPWiz Zh64zPYXH+zfRIuEiYJyiAb1WhhQdXzQWtdjt/Bf7WgbOq0nP05YBQ7TzC+N21fpYJkH uqYrP4rU01aDzoMZHvgG8HA++JLECugWr9OiNzwMBX67ICJvSJHU9tZgT2Lpy0QmaYog a/fw== 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 z17si259811eda.610.2020.11.30.19.02.58; Mon, 30 Nov 2020 19:03:21 -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 S1726950AbgLAC7W (ORCPT + 99 others); Mon, 30 Nov 2020 21:59:22 -0500 Received: from namei.org ([65.99.196.166]:57156 "EHLO namei.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbgLAC7W (ORCPT ); Mon, 30 Nov 2020 21:59:22 -0500 Received: from localhost (localhost [127.0.0.1]) by namei.org (8.14.4/8.14.4) with ESMTP id 0B12wPRU029210; Tue, 1 Dec 2020 02:58:25 GMT Date: Tue, 1 Dec 2020 13:58:25 +1100 (AEDT) From: James Morris To: "Serge E. Hallyn" cc: "Andrew G. Morgan" , lkml , =?ISO-8859-15?Q?Herv=E9_Guillemet?= , Casey Schaufler Subject: Re: [PATCH] fix namespaced fscaps when !CONFIG_SECURITY In-Reply-To: <20201129211542.GA5227@mail.hallyn.com> Message-ID: References: <20201117150856.GA12240@mail.hallyn.com> <20201129211542.GA5227@mail.hallyn.com> User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1665246916-1019167516-1606791505=:28022" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1665246916-1019167516-1606791505=:28022 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT On Sun, 29 Nov 2020, Serge E. Hallyn wrote: > 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 ) Sure. > > 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 > > > > > > > -- James Morris --1665246916-1019167516-1606791505=:28022--