1. 08 Feb, 2021 1 commit
  2. 05 Feb, 2021 2 commits
    • Bob Peterson's avatar
      gfs2: Don't skip dlm unlock if glock has an lvb · 78178ca8
      Bob Peterson authored
      Patch fb6791d1 was designed to allow gfs2 to unmount quicker by
      skipping the step where it tells dlm to unlock glocks in EX with lvbs.
      This was done because when gfs2 unmounts a file system, it destroys the
      dlm lockspace shortly after it destroys the glocks so it doesn't need to
      unlock them all: the unlock is implied when the lockspace is destroyed
      by dlm.
      
      However, that patch introduced a use-after-free in dlm: as part of its
      normal dlm_recoverd process, it can call ls_recovery to recover dead
      locks. In so doing, it can call recover_rsbs which calls recover_lvb for
      any mastered rsbs. Func recover_lvb runs through the list of lkbs queued
      to the given rsb (if the glock is cached but unlocked, it will still be
      queued to the lkb, but in NL--Unlocked--mode) and if it has an lvb,
      copies it to the rsb, thus trying to preserve the lkb. However, when
      gfs2 skips the dlm unlock step, it frees the glock and its lvb, which
      means dlm's function recover_lvb references the now freed lvb pointer,
      copying the freed lvb memory to the rsb.
      
      This patch changes the check in gdlm_put_lock so that it calls
      dlm_unlock for all glocks that contain an lvb pointer.
      
      Fixes: fb6791d1 ("GFS2: skip dlm_unlock calls in unmount")
      Cc: stable@vger.kernel.org # v3.8+
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      78178ca8
    • Andreas Gruenbacher's avatar
      gfs2: Lock imbalance on error path in gfs2_recover_one · 834ec3e1
      Andreas Gruenbacher authored
      In gfs2_recover_one, fix a sd_log_flush_lock imbalance when a recovery
      pass fails.
      
      Fixes: c9ebc4b7 ("gfs2: allow journal replay to hold sd_log_flush_lock")
      Cc: stable@vger.kernel.org # v5.7+
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      834ec3e1
  3. 25 Jan, 2021 4 commits
  4. 22 Jan, 2021 1 commit
  5. 31 Dec, 2020 1 commit
  6. 22 Dec, 2020 2 commits
    • Bob Peterson's avatar
      gfs2: move freeze glock outside the make_fs_rw and _ro functions · 96b1454f
      Bob Peterson authored
      Before this patch, sister functions gfs2_make_fs_rw and gfs2_make_fs_ro locked
      (held) the freeze glock by calling gfs2_freeze_lock and gfs2_freeze_unlock.
      The problem is, not all the callers of gfs2_make_fs_ro should be doing this.
      The three callers of gfs2_make_fs_ro are: remount (gfs2_reconfigure),
      signal_our_withdraw, and unmount (gfs2_put_super). But when unmounting the
      file system we can get into the following circular lock dependency:
      
      deactivate_super
         down_write(&s->s_umount); <-------------------------------------- s_umount
         deactivate_locked_super
            gfs2_kill_sb
               kill_block_super
                  generic_shutdown_super
                     gfs2_put_super
                        gfs2_make_fs_ro
                           gfs2_glock_nq_init sd_freeze_gl
                              freeze_go_sync
                                 if (freeze glock in SH)
                                    freeze_super (vfs)
                                       down_write(&sb->s_umount); <------- s_umount
      
      This patch moves the hold of the freeze glock outside the two sister rw/ro
      functions to their callers, but it doesn't request the glock from
      gfs2_put_super, thus eliminating the circular dependency.
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      96b1454f
    • Bob Peterson's avatar
      gfs2: Add common helper for holding and releasing the freeze glock · c77b52c0
      Bob Peterson authored
      Many places in the gfs2 code queued and dequeued the freeze glock.
      Almost all of them acquire it in SHARED mode, and need to specify the
      same LM_FLAG_NOEXP and GL_EXACT flags.
      
      This patch adds common helper functions gfs2_freeze_lock and gfs2_freeze_unlock
      to make the code more readable, and to prepare for the next patch.
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      c77b52c0
  7. 20 Dec, 2020 2 commits
  8. 19 Dec, 2020 27 commits