1. 24 1月, 2021 4 次提交
    • C
      xfs: support idmapped mounts · f736d93d
      Christoph Hellwig 提交于
      Enable idmapped mounts for xfs. This basically just means passing down
      the user_namespace argument from the VFS methods down to where it is
      passed to the relevant helpers.
      
      Note that full-filesystem bulkstat is not supported from inside idmapped
      mounts as it is an administrative operation that acts on the whole file
      system. The limitation is not applied to the bulkstat single operation
      that just operates on a single inode.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-40-christian.brauner@ubuntu.comSigned-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      f736d93d
    • C
      fs: make helpers idmap mount aware · 549c7297
      Christian Brauner 提交于
      Extend some inode methods with an additional user namespace argument. A
      filesystem that is aware of idmapped mounts will receive the user
      namespace the mount has been marked with. This can be used for
      additional permission checking and also to enable filesystems to
      translate between uids and gids if they need to. We have implemented all
      relevant helpers in earlier patches.
      
      As requested we simply extend the exisiting inode method instead of
      introducing new ones. This is a little more code churn but it's mostly
      mechanical and doesnt't leave us with additional inode methods.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-25-christian.brauner@ubuntu.com
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      549c7297
    • C
      acl: handle idmapped mounts · e65ce2a5
      Christian Brauner 提交于
      The posix acl permission checking helpers determine whether a caller is
      privileged over an inode according to the acls associated with the
      inode. Add helpers that make it possible to handle acls on idmapped
      mounts.
      
      The vfs and the filesystems targeted by this first iteration make use of
      posix_acl_fix_xattr_from_user() and posix_acl_fix_xattr_to_user() to
      translate basic posix access and default permissions such as the
      ACL_USER and ACL_GROUP type according to the initial user namespace (or
      the superblock's user namespace) to and from the caller's current user
      namespace. Adapt these two helpers to handle idmapped mounts whereby we
      either map from or into the mount's user namespace depending on in which
      direction we're translating.
      Similarly, cap_convert_nscap() is used by the vfs to translate user
      namespace and non-user namespace aware filesystem capabilities from the
      superblock's user namespace to the caller's user namespace. Enable it to
      handle idmapped mounts by accounting for the mount's user namespace.
      
      In addition the fileystems targeted in the first iteration of this patch
      series make use of the posix_acl_chmod() and, posix_acl_update_mode()
      helpers. Both helpers perform permission checks on the target inode. Let
      them handle idmapped mounts. These two helpers are called when posix
      acls are set by the respective filesystems to handle this case we extend
      the ->set() method to take an additional user namespace argument to pass
      the mount's user namespace down.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-9-christian.brauner@ubuntu.com
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      e65ce2a5
    • C
      attr: handle idmapped mounts · 2f221d6f
      Christian Brauner 提交于
      When file attributes are changed most filesystems rely on the
      setattr_prepare(), setattr_copy(), and notify_change() helpers for
      initialization and permission checking. Let them handle idmapped mounts.
      If the inode is accessed through an idmapped mount map it into the
      mount's user namespace. Afterwards the checks are identical to
      non-idmapped mounts. If the initial user namespace is passed nothing
      changes so non-idmapped mounts will see identical behavior as before.
      
      Helpers that perform checks on the ia_uid and ia_gid fields in struct
      iattr assume that ia_uid and ia_gid are intended values and have already
      been mapped correctly at the userspace-kernelspace boundary as we
      already do today. If the initial user namespace is passed nothing
      changes so non-idmapped mounts will see identical behavior as before.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-8-christian.brauner@ubuntu.com
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      2f221d6f
  2. 13 12月, 2020 2 次提交
  3. 10 12月, 2020 1 次提交
  4. 05 11月, 2020 1 次提交
    • B
      xfs: flush new eof page on truncate to avoid post-eof corruption · 869ae85d
      Brian Foster 提交于
      It is possible to expose non-zeroed post-EOF data in XFS if the new
      EOF page is dirty, backed by an unwritten block and the truncate
      happens to race with writeback. iomap_truncate_page() will not zero
      the post-EOF portion of the page if the underlying block is
      unwritten. The subsequent call to truncate_setsize() will, but
      doesn't dirty the page. Therefore, if writeback happens to complete
      after iomap_truncate_page() (so it still sees the unwritten block)
      but before truncate_setsize(), the cached page becomes inconsistent
      with the on-disk block. A mapped read after the associated page is
      reclaimed or invalidated exposes non-zero post-EOF data.
      
      For example, consider the following sequence when run on a kernel
      modified to explicitly flush the new EOF page within the race
      window:
      
      $ xfs_io -fc "falloc 0 4k" -c fsync /mnt/file
      $ xfs_io -c "pwrite 0 4k" -c "truncate 1k" /mnt/file
        ...
      $ xfs_io -c "mmap 0 4k" -c "mread -v 1k 8" /mnt/file
      00000400:  00 00 00 00 00 00 00 00  ........
      $ umount /mnt/; mount <dev> /mnt/
      $ xfs_io -c "mmap 0 4k" -c "mread -v 1k 8" /mnt/file
      00000400:  cd cd cd cd cd cd cd cd  ........
      
      Update xfs_setattr_size() to explicitly flush the new EOF page prior
      to the page truncate to ensure iomap has the latest state of the
      underlying block.
      
      Fixes: 68a9f5e7 ("xfs: implement iomap based buffered write path")
      Signed-off-by: NBrian Foster <bfoster@redhat.com>
      Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      869ae85d
  5. 26 9月, 2020 1 次提交
  6. 10 6月, 2020 1 次提交
  7. 04 6月, 2020 1 次提交
  8. 30 5月, 2020 3 次提交
  9. 20 5月, 2020 1 次提交
  10. 05 5月, 2020 4 次提交
  11. 19 3月, 2020 1 次提交
  12. 03 3月, 2020 4 次提交
  13. 10 1月, 2020 1 次提交
  14. 14 11月, 2019 3 次提交
  15. 11 11月, 2019 2 次提交
  16. 05 11月, 2019 1 次提交
  17. 30 10月, 2019 5 次提交
  18. 28 10月, 2019 1 次提交
  19. 22 10月, 2019 2 次提交
  20. 23 8月, 2019 1 次提交
    • D
      xfs: fix missing ILOCK unlock when xfs_setattr_nonsize fails due to EDQUOT · 1fb254aa
      Darrick J. Wong 提交于
      Benjamin Moody reported to Debian that XFS partially wedges when a chgrp
      fails on account of being out of disk quota.  I ran his reproducer
      script:
      
      # adduser dummy
      # adduser dummy plugdev
      
      # dd if=/dev/zero bs=1M count=100 of=test.img
      # mkfs.xfs test.img
      # mount -t xfs -o gquota test.img /mnt
      # mkdir -p /mnt/dummy
      # chown -c dummy /mnt/dummy
      # xfs_quota -xc 'limit -g bsoft=100k bhard=100k plugdev' /mnt
      
      (and then as user dummy)
      
      $ dd if=/dev/urandom bs=1M count=50 of=/mnt/dummy/foo
      $ chgrp plugdev /mnt/dummy/foo
      
      and saw:
      
      ================================================
      WARNING: lock held when returning to user space!
      5.3.0-rc5 #rc5 Tainted: G        W
      ------------------------------------------------
      chgrp/47006 is leaving the kernel with locks still held!
      1 lock held by chgrp/47006:
       #0: 000000006664ea2d (&xfs_nondir_ilock_class){++++}, at: xfs_ilock+0xd2/0x290 [xfs]
      
      ...which is clearly caused by xfs_setattr_nonsize failing to unlock the
      ILOCK after the xfs_qm_vop_chown_reserve call fails.  Add the missing
      unlock.
      
      Reported-by: benjamin.moody@gmail.com
      Fixes: 253f4911 ("xfs: better xfs_trans_alloc interface")
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Tested-by: NSalvatore Bonaccorso <carnil@debian.org>
      1fb254aa