linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY
@ 2020-12-10 22:16 James Morris
  0 siblings, 0 replies; only message in thread
From: James Morris @ 2020-12-10 22:16 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, linux-security-module, Serge E. Hallyn

[-- Attachment #1: Type: text/plain, Size: 3239 bytes --]

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 <shallyn@cisco.com>
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 <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>

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)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-10 23:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 22:16 [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).