]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - fs/gfs2/lock_dlm.c
gfs2: fix slab corruption during mounting and umounting gfs file system
authorThomas Tai <thomas.tai@oracle.com>
Tue, 15 Aug 2017 16:54:09 +0000 (11:54 -0500)
committerBob Peterson <rpeterso@redhat.com>
Tue, 15 Aug 2017 16:54:09 +0000 (11:54 -0500)
commitcc1dfa8b7571ea16dec9a29e0f4c4cad90b2a761
tree0c146e4e688cd937d03188661a3ada788db84105
parentb066a4eebd4f5ea77f7e5c7d13104d38e1a1d4bf
gfs2: fix slab corruption during mounting and umounting gfs file system

When using cman-3.0.12.1 and gfs2-utils-3.0.12.1, mounting and
unmounting GFS2 file system would cause kernel to hang. The slab
allocator suggests that it is likely a double free memory corruption.
The issue is traced back to v3.9-rc6 where a patch is submitted to
use kzalloc() for storing a bitmap instead of using a local variable.
The intention is to allocate memory during mount and to free memory
during unmount. The original patch misses a code path which has
already freed the memory and caused memory corruption. This patch sets
the memory pointer to NULL after the memory is freed, so that double
free memory corruption will not happen.

gdlm_mount()
  '-- set_recover_size() which use kzalloc()
  '-- if dlm does not support ops callbacks then
          '--- free_recover_size() which use kfree()

gldm_unmount()
  '-- free_recover_size() which use kfree()

Previous patch which introduced the double free issue is
commit 57c7310b8eb9 ("GFS2: use kmalloc for lvb bitmap")

Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
fs/gfs2/lock_dlm.c