Merge tag 'fixes-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 28 Apr 2021 02:32:55 +0000 (19:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 28 Apr 2021 02:32:55 +0000 (19:32 -0700)
Pull security layer fixes from James Morris:
 "Miscellaneous minor fixes"

* tag 'fixes-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
  security: commoncap: clean up kernel-doc comments
  security: commoncap: fix -Wstringop-overread warning

1  2 
security/commoncap.c

@@@ -309,15 -307,9 +309,15 @@@ int cap_inode_need_killpriv(struct dent
   *
   * Erase the privilege-enhancing security markings on an inode.
   *
-  * Returns 0 if successful, -ve on error.
 + * If the inode has been found through an idmapped mount the user namespace of
 + * the vfsmount must be passed through @mnt_userns. This function will then
 + * take care to map the inode according to @mnt_userns before checking
 + * permissions. On non-idmapped mounts or if permission checking is to be
 + * performed on the raw inode simply passs init_user_ns.
 + *
+  * Return: 0 if successful, -ve on error.
   */
 -int cap_inode_killpriv(struct dentry *dentry)
 +int cap_inode_killpriv(struct user_namespace *mnt_userns, struct dentry *dentry)
  {
        int error;
  
@@@ -396,11 -387,11 +396,11 @@@ int cap_inode_getsecurity(struct user_n
                return -EINVAL;
  
        size = sizeof(struct vfs_ns_cap_data);
 -      ret = (int) vfs_getxattr_alloc(dentry, XATTR_NAME_CAPS,
 -                               &tmpbuf, size, GFP_NOFS);
 +      ret = (int)vfs_getxattr_alloc(mnt_userns, dentry, XATTR_NAME_CAPS,
 +                                    &tmpbuf, size, GFP_NOFS);
        dput(dentry);
  
-       if (ret < 0)
+       if (ret < 0 || !tmpbuf)
                return ret;
  
        fs_ns = inode->i_sb->s_user_ns;
@@@ -526,16 -490,9 +526,16 @@@ static bool validheader(size_t size, co
   * User requested a write of security.capability.  If needed, update the
   * xattr to change from v2 to v3, or to fixup the v3 rootid.
   *
-  * If all is ok, we return the new size, on error return < 0.
 + * If the inode has been found through an idmapped mount the user namespace of
 + * the vfsmount must be passed through @mnt_userns. This function will then
 + * take care to map the inode according to @mnt_userns before checking
 + * permissions. On non-idmapped mounts or if permission checking is to be
 + * performed on the raw inode simply passs init_user_ns.
 + *
+  * Return: On success, return the new size; on error, return < 0.
   */
 -int cap_convert_nscap(struct dentry *dentry, const void **ivalue, size_t size)
 +int cap_convert_nscap(struct user_namespace *mnt_userns, struct dentry *dentry,
 +                    const void **ivalue, size_t size)
  {
        struct vfs_ns_cap_data *nscap;
        uid_t nsrootid;