]> Git Repo - linux.git/commitdiff
Merge tag 'fs.idmapped.fixes.v6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <[email protected]>
Mon, 22 Aug 2022 18:33:02 +0000 (11:33 -0700)
committerLinus Torvalds <[email protected]>
Mon, 22 Aug 2022 18:33:02 +0000 (11:33 -0700)
Pull idmapping fixes from Christian Brauner:

 - Since Seth joined as co-maintainer for idmapped mounts we decided to
   use a shared git tree. Konstantin suggested we use vfs/idmapping.git
   on kernel.org under the vfs/ namespace. So this updates the tree in
   the maintainers file.

 - Ensure that POSIX ACLs checking, getting, and setting works correctly
   for filesystems mountable with a filesystem idmapping that want to
   support idmapped mounts.

   Since no filesystems mountable with an fs_idmapping do yet support
   idmapped mounts there is no problem. But this could change in the
   future, so add a check to refuse to create idmapped mounts when the
   mounter is not privileged over the mount's idmapping.

 - Check that caller is privileged over the idmapping that will be
   attached to a mount.

   Currently no FS_USERNS_MOUNT filesystems support idmapped mounts,
   thus this is not a problem as only CAP_SYS_ADMIN in init_user_ns is
   allowed to set up idmapped mounts. But this could change in the
   future, so add a check to refuse to create idmapped mounts when the
   mounter is not privileged over the mount's idmapping.

 - Fix POSIX ACLs for ntfs3. While looking at our current POSIX ACL
   handling in the context of some overlayfs work I went through a range
   of other filesystems checking how they handle them currently and
   encountered a few bugs in ntfs3.

   I've sent this some time ago and the fixes haven't been picked up
   even though the pull request for other ntfs3 fixes got sent after.
   This should really be fixed as right now POSIX ACLs are broken in
   certain circumstances for ntfs3.

* tag 'fs.idmapped.fixes.v6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping:
  ntfs: fix acl handling
  fs: require CAP_SYS_ADMIN in target namespace for idmapped mounts
  MAINTAINERS: update idmapping tree
  acl: handle idmapped mounts for idmapped filesystems

1  2 
MAINTAINERS
fs/ntfs3/xattr.c

diff --combined MAINTAINERS
index 9d7f64dc0efe81bce57b80ef78ef9affe86b2c36,a558794dddf9151d11e163f0000b6d62af29cea1..96f47a7865d60ad8e4635639c7b7fe241cc85e3d
@@@ -2178,7 -2178,7 +2178,7 @@@ M:      Jean-Marie Verdun <[email protected]
  M:    Nick Hawkins <[email protected]>
  S:    Maintained
  F:    Documentation/devicetree/bindings/arm/hpe,gxp.yaml
 -F:    Documentation/devicetree/bindings/spi/hpe,gxp-spi.yaml
 +F:    Documentation/devicetree/bindings/spi/hpe,gxp-spifi.yaml
  F:    Documentation/devicetree/bindings/timer/hpe,gxp-timer.yaml
  F:    arch/arm/boot/dts/hpe-bmc*
  F:    arch/arm/boot/dts/hpe-gxp*
@@@ -5145,7 -5145,6 +5145,7 @@@ T:      git git://git.samba.org/sfrench/cifs
  F:    Documentation/admin-guide/cifs/
  F:    fs/cifs/
  F:    fs/smbfs_common/
 +F:    include/uapi/linux/cifs
  
  COMPACTPCI HOTPLUG CORE
  M:    Scott Murray <[email protected]>
@@@ -9781,7 -9780,7 +9781,7 @@@ M:      Christian Brauner <[email protected]
  M:    Seth Forshee <[email protected]>
  L:    [email protected]
  S:    Maintained
- T:    git git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
+ T:    git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping.git
  F:    Documentation/filesystems/idmappings.rst
  F:    tools/testing/selftests/mount_setattr/
  F:    include/linux/mnt_idmapping.h
diff --combined fs/ntfs3/xattr.c
index 5bdff12a1232dbcef7ae04e5efd3d91f56034ada,3e9118705174fcb6017b95d98400ffa9dec249bf..6ae1f56b7358ff97a36be66e07e85c4c47b6a4dd
@@@ -118,7 -118,7 +118,7 @@@ static int ntfs_read_ea(struct ntfs_ino
  
                run_init(&run);
  
 -              err = attr_load_runs(attr_ea, ni, &run, NULL);
 +              err = attr_load_runs_range(ni, ATTR_EA, NULL, 0, &run, 0, size);
                if (!err)
                        err = ntfs_read_run_nb(sbi, &run, 0, ea_p, size, NULL);
                run_close(&run);
@@@ -444,11 -444,6 +444,11 @@@ update_ea
                /* Delete xattr, ATTR_EA */
                ni_remove_attr_le(ni, attr, mi, le);
        } else if (attr->non_res) {
 +              err = attr_load_runs_range(ni, ATTR_EA, NULL, 0, &ea_run, 0,
 +                                         size);
 +              if (err)
 +                      goto out;
 +
                err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size, 0);
                if (err)
                        goto out;
@@@ -483,8 -478,7 +483,7 @@@ out
  }
  
  #ifdef CONFIG_NTFS3_FS_POSIX_ACL
- static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
-                                        struct inode *inode, int type,
+ static struct posix_acl *ntfs_get_acl_ex(struct inode *inode, int type,
                                         int locked)
  {
        struct ntfs_inode *ni = ntfs_i(inode);
  
        /* Translate extended attribute to acl. */
        if (err >= 0) {
-               acl = posix_acl_from_xattr(mnt_userns, buf, err);
+               acl = posix_acl_from_xattr(&init_user_ns, buf, err);
        } else if (err == -ENODATA) {
                acl = NULL;
        } else {
@@@ -542,8 -536,7 +541,7 @@@ struct posix_acl *ntfs_get_acl(struct i
        if (rcu)
                return ERR_PTR(-ECHILD);
  
-       /* TODO: init_user_ns? */
-       return ntfs_get_acl_ex(&init_user_ns, inode, type, 0);
+       return ntfs_get_acl_ex(inode, type, 0);
  }
  
  static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
  {
        const char *name;
        size_t size, name_len;
 -      void *value = NULL;
 -      int err = 0;
 +      void *value;
 +      int err;
        int flags;
 +      umode_t mode;
  
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
  
 +      mode = inode->i_mode;
        switch (type) {
        case ACL_TYPE_ACCESS:
                /* Do not change i_mode if we are in init_acl */
                if (acl && !init_acl) {
 -                      umode_t mode;
 -
                        err = posix_acl_update_mode(mnt_userns, inode, &mode,
                                                    &acl);
                        if (err)
 -                              goto out;
 -
 -                      if (inode->i_mode != mode) {
 -                              inode->i_mode = mode;
 -                              mark_inode_dirty(inode);
 -                      }
 +                              return err;
                }
                name = XATTR_NAME_POSIX_ACL_ACCESS;
                name_len = sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1;
                value = kmalloc(size, GFP_NOFS);
                if (!value)
                        return -ENOMEM;
-               err = posix_acl_to_xattr(mnt_userns, acl, value, size);
+               err = posix_acl_to_xattr(&init_user_ns, acl, value, size);
                if (err < 0)
                        goto out;
                flags = 0;
        err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
        if (err == -ENODATA && !size)
                err = 0; /* Removing non existed xattr. */
 -      if (!err)
 +      if (!err) {
                set_cached_acl(inode, type, acl);
 +              if (inode->i_mode != mode) {
 +                      inode->i_mode = mode;
 +                      mark_inode_dirty(inode);
 +              }
 +      }
  
  out:
        kfree(value);
@@@ -646,7 -639,7 +644,7 @@@ static int ntfs_xattr_get_acl(struct us
        if (!acl)
                return -ENODATA;
  
-       err = posix_acl_to_xattr(mnt_userns, acl, buffer, size);
+       err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
        posix_acl_release(acl);
  
        return err;
@@@ -670,12 -663,12 +668,12 @@@ static int ntfs_xattr_set_acl(struct us
        if (!value) {
                acl = NULL;
        } else {
-               acl = posix_acl_from_xattr(mnt_userns, value, size);
+               acl = posix_acl_from_xattr(&init_user_ns, value, size);
                if (IS_ERR(acl))
                        return PTR_ERR(acl);
  
                if (acl) {
-                       err = posix_acl_valid(mnt_userns, acl);
+                       err = posix_acl_valid(&init_user_ns, acl);
                        if (err)
                                goto release_and_out;
                }
@@@ -711,13 -704,13 +709,13 @@@ int ntfs_init_acl(struct user_namespac
                inode->i_default_acl = NULL;
        }
  
 -      if (!acl)
 -              inode->i_acl = NULL;
 -      else {
 +      if (acl) {
                if (!err)
                        err = ntfs_set_acl_ex(mnt_userns, inode, acl,
                                              ACL_TYPE_ACCESS, true);
                posix_acl_release(acl);
 +      } else {
 +              inode->i_acl = NULL;
        }
  
        return err;
This page took 0.139473 seconds and 4 git commands to generate.