Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp281646pxu; Fri, 11 Dec 2020 02:09:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxR2DoDm/GrkliWSVrVLLi/EiVLZpnwhiQQ9fitpQ+s7TNUrH1D+ua8CZ/F3MA0+2MTV3Nq X-Received: by 2002:a17:907:4243:: with SMTP id np3mr10076330ejb.212.1607681345534; Fri, 11 Dec 2020 02:09:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607681345; cv=none; d=google.com; s=arc-20160816; b=fSRpNHGF0YjXcUxbRIQvYBjhi/1eqlajKJCBsJ7nh695dgY0XqVgZRuveiaBzJCBWu 64Q87gos3XjJsVAAwH+YXU7wssABIotSCjymnqffzps2f5FkFokCaoRWCUFc16Kqpzs3 q8x24F65SRDNTSm2cwTBUrJpz1rUAAkPEv0exCxuVezrM3hx91kCBYGOBm7uyeLPgB++ qSzYelNbVwe6lD+wixRgXksgnfRsYyJ/QHZaoPsUUcoxRtytLaCpwZVOLHGFxt4jJdxQ wYRDtahIDKf9UQnn/ypkJH82U5e5nklI35EMfKzlTwe0YkdZt3h6UzzyCeVB78A8dg1m TmoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:subject:cc:to:from:date; bh=U4JINJsYrQNkVJfSHL3QPnbjXTNQ65DVPm8VgdbDNYg=; b=O2DzlYYDzwf8mHbtvjybvCGRba12mVTe1/8D7ilnonEA7sQ1ZfTA5raKx1Fh6EATYN 2pXsAj6nKEZbYat6hNNsqFzazR5VLBvUgZFfuyPMejQ8rocZA2KUt066DIqyQ6o0Q7g5 ixTDCbGNgObarfjnoZSpIHBSGbrdxVasofG++vmriRagiNCIEHLiQcJOELdSkiggBS5U MPNXzw5K5dDwWif0mSLrmKpl1lzx/rcASYaPjLCzOoS8RGJeC1AwlybH3B/4C54/kzi7 nUBqogK8MFJ2yIVkGxxnFfdXaK9zsgGyaWs205EcbFnvntCYhQWIUl4t0WubSRT2iZiU Ctmw== 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 s28si4272608edc.569.2020.12.11.02.08.42; Fri, 11 Dec 2020 02:09:05 -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 S2405109AbgLJWbq (ORCPT + 99 others); Thu, 10 Dec 2020 17:31:46 -0500 Received: from namei.org ([65.99.196.166]:60274 "EHLO mail.namei.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405118AbgLJWYm (ORCPT ); Thu, 10 Dec 2020 17:24:42 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.namei.org (Postfix) with ESMTPS id 28F6DDBF; Thu, 10 Dec 2020 22:16:53 +0000 (UTC) Date: Fri, 11 Dec 2020 09:16:53 +1100 (AEDT) From: James Morris To: Linus Torvalds cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, "Serge E. Hallyn" Subject: [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1665246916-1130980013-1607638613=:97768" 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-1130980013-1607638613=:97768 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT Please apply this config bugfix from Serge Hallyn. The following changes since commit bbf5c979011a099af5dc76498918ed7df445635b: Linux 5.9 (2020-10-11 14:15:50 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git tags/fixes-v5.10a for you to fetch changes up to ed9b25d1970a4787ac6a39c2091e63b127ecbfc1: [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY (2020-12-04 16:24:11 -0800) ---------------------------------------------------------------- Fix namespaced fscaps when !CONFIG_SECURITY from Serge Hallyn. ---------------------------------------------------------------- Serge Hallyn (1): [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY include/linux/security.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) commit ed9b25d1970a4787ac6a39c2091e63b127ecbfc1 Author: Serge Hallyn Date: Sun Nov 15 21:55:31 2020 -0600 [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY 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. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209689 Cc: Herv? Guillemet Acked-by: Casey Schaufler Signed-off-by: Serge Hallyn Signed-off-by: Andrew G. Morgan Signed-off-by: James Morris diff --git a/include/linux/security.h b/include/linux/security.h index 0a0a03b36a3b..2befc0a25eb3 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -864,7 +864,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) --1665246916-1130980013-1607638613=:97768--