OSDN Git Service

Merge tag 'xfs-5.17-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 11 Jan 2022 23:01:50 +0000 (15:01 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 11 Jan 2022 23:01:50 +0000 (15:01 -0800)
Pull xfs updates from Darrick Wong:
 "The big new feature here is that the mount code now only bothers to
  try to free stale COW staging extents if the fs unmounted uncleanly.
  This should reduce mount times, particularly on filesystems supporting
  reflink and containing a large number of allocation groups.

  Everything else this cycle are bugfixes, as the iomap folios
  conversion should be plenty enough excitement for anyone. That and I
  ran out of brain bandwidth after Thanksgiving last year.

  Summary:

   - Fix log recovery with da btree buffers when metauuid is in use.

   - Fix type coercion problems in xattr buffer size validation.

   - Fix a bug in online scrub dir leaf bestcount checking.

   - Only run COW recovery when recovering the log.

   - Fix symlink target buffer UAF problems and symlink locking problems
     by not exposing xfs innards to the VFS.

   - Fix incorrect quotaoff lock usage.

   - Don't let transactions cancel cleanly if they have deferred work
     items attached.

   - Fix a UAF when we're deciding if we need to relog an intent item.

   - Reduce kvmalloc overhead for log shadow buffers.

   - Clean up sysfs attr group usage.

   - Fix a bug where scrub's bmap/rmap checking could race with a quota
     file block allocation due to insufficient locking.

   - Teach scrub to complain about invalid project ids"

* tag 'xfs-5.17-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: warn about inodes with project id of -1
  xfs: hold quota inode ILOCK_EXCL until the end of dqalloc
  xfs: Remove redundant assignment of mp
  xfs: reduce kvmalloc overhead for CIL shadow buffers
  xfs: sysfs: use default_groups in kobj_type
  xfs: prevent UAF in xfs_log_item_in_current_chkpt
  xfs: prevent a WARN_ONCE() in xfs_ioc_attr_list()
  xfs: Fix comments mentioning xfs_ialloc
  xfs: check sb_meta_uuid for dabuf buffer recovery
  xfs: fix a bug in the online fsck directory leaf1 bestcount check
  xfs: only run COW extent recovery when there are no live extents
  xfs: don't expose internal symlink metadata buffers to the vfs
  xfs: fix quotaoff mutex usage now that we don't support disabling it
  xfs: shut down filesystem if we xfs_trans_cancel with deferred work items

1  2 
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_symlink.c

diff --combined fs/xfs/xfs_ioctl.c
@@@ -372,7 -372,7 +372,7 @@@ in
  xfs_ioc_attr_list(
        struct xfs_inode                *dp,
        void __user                     *ubuf,
-       int                             bufsize,
+       size_t                          bufsize,
        int                             flags,
        struct xfs_attrlist_cursor __user *ucursor)
  {
@@@ -687,8 -687,7 +687,8 @@@ xfs_ioc_space
  
        if (bf->l_start > XFS_ISIZE(ip)) {
                error = xfs_alloc_file_space(ip, XFS_ISIZE(ip),
 -                              bf->l_start - XFS_ISIZE(ip), 0);
 +                              bf->l_start - XFS_ISIZE(ip),
 +                              XFS_BMAPI_PREALLOC);
                if (error)
                        goto out_unlock;
        }
diff --combined fs/xfs/xfs_symlink.c
@@@ -22,6 -22,7 +22,7 @@@
  #include "xfs_trace.h"
  #include "xfs_trans.h"
  #include "xfs_ialloc.h"
+ #include "xfs_error.h"
  
  /* ----- Kernel only functions below ----- */
  int
@@@ -96,17 -97,15 +97,15 @@@ xfs_readlink_bmap_ilocked
  
  int
  xfs_readlink(
-       struct xfs_inode *ip,
-       char            *link)
+       struct xfs_inode        *ip,
+       char                    *link)
  {
-       struct xfs_mount *mp = ip->i_mount;
-       xfs_fsize_t     pathlen;
-       int             error = 0;
+       struct xfs_mount        *mp = ip->i_mount;
+       xfs_fsize_t             pathlen;
+       int                     error = -EFSCORRUPTED;
  
        trace_xfs_readlink(ip);
  
-       ASSERT(ip->i_df.if_format != XFS_DINODE_FMT_LOCAL);
        if (xfs_is_shutdown(mp))
                return -EIO;
  
                         __func__, (unsigned long long) ip->i_ino,
                         (long long) pathlen);
                ASSERT(0);
-               error = -EFSCORRUPTED;
                goto out;
        }
  
-       error = xfs_readlink_bmap_ilocked(ip, link);
+       if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) {
+               /*
+                * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED
+                * if if_data is junk.
+                */
+               if (XFS_IS_CORRUPT(ip->i_mount, !ip->i_df.if_u1.if_data))
+                       goto out;
+               memcpy(link, ip->i_df.if_u1.if_data, pathlen + 1);
+               error = 0;
+       } else {
+               error = xfs_readlink_bmap_ilocked(ip, link);
+       }
  
   out:
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
@@@ -184,8 -193,8 +193,8 @@@ xfs_symlink
        /*
         * Make sure that we have allocated dquot(s) on disk.
         */
 -      error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(mnt_userns),
 -                      mapped_fsgid(mnt_userns), prid,
 +      error = xfs_qm_vop_dqalloc(dp, mapped_fsuid(mnt_userns, &init_user_ns),
 +                      mapped_fsgid(mnt_userns, &init_user_ns), prid,
                        XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
                        &udqp, &gdqp, &pdqp);
        if (error)