From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Serge Hallyn" <shallyn@cisco.com>,
"Hervé Guillemet" <herve@guillemet.org>,
"Casey Schaufler" <casey@schaufler-ca.com>,
"Andrew G . Morgan" <morgan@kernel.org>,
"James Morris" <jamorris@linux.microsoft.com>,
"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.4 03/10] [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY
Date: Sat, 19 Dec 2020 22:34:50 -0500 [thread overview]
Message-ID: <20201220033457.2728519-3-sashal@kernel.org> (raw)
In-Reply-To: <20201220033457.2728519-1-sashal@kernel.org>
From: Serge Hallyn <shallyn@cisco.com>
[ Upstream commit ed9b25d1970a4787ac6a39c2091e63b127ecbfc1 ]
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 <herve@guillemet.org>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Serge Hallyn <shallyn@cisco.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Signed-off-by: James Morris <jamorris@linux.microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 fd022768e91df..df90399a8af98 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -852,7 +852,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.27.0
next prev parent reply other threads:[~2020-12-20 3:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-20 3:34 [PATCH AUTOSEL 5.4 01/10] ARM: sunxi: Add machine match for the Allwinner V3 SoC Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 02/10] cfg80211: initialize rekey_data Sasha Levin
2020-12-20 3:34 ` Sasha Levin [this message]
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 04/10] lwt: Disable BH too in run_lwt_bpf() Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 05/10] drm/amd/display: Prevent bandwidth overflow Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 06/10] drm/amdkfd: Fix leak in dmabuf import Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 07/10] Input: cros_ec_keyb - send 'scancodes' in addition to key events Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 08/10] selftests/bpf: Fix array access with signed variable test Sasha Levin
2020-12-20 12:05 ` Jean-Philippe Brucker
2020-12-21 19:09 ` Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 09/10] initramfs: fix clang build failure Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.4 10/10] Input: goodix - add upside-down quirk for Teclast X98 Pro tablet Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201220033457.2728519-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=casey@schaufler-ca.com \
--cc=herve@guillemet.org \
--cc=jamorris@linux.microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=morgan@kernel.org \
--cc=shallyn@cisco.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox