]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free
authorBob Peterson <rpeterso@redhat.com>
Tue, 27 Oct 2020 15:10:01 +0000 (10:10 -0500)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 29 Oct 2020 21:16:36 +0000 (22:16 +0100)
Function gfs2_clear_rgrpd calls kfree(rgd->rd_bits) before calling
return_all_reservations, but return_all_reservations still dereferences
rgd->rd_bits in __rs_deltree.  Fix that by moving the call to kfree below the
call to return_all_reservations.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/rgrp.c

index ee491bb9c1ccdcdef39bf233830cd82519f87963..eb1b29734b7f521a95993be4d1388ac2ed0535cf 100644 (file)
@@ -719,9 +719,9 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)
                }
 
                gfs2_free_clones(rgd);
+               return_all_reservations(rgd);
                kfree(rgd->rd_bits);
                rgd->rd_bits = NULL;
-               return_all_reservations(rgd);
                kmem_cache_free(gfs2_rgrpd_cachep, rgd);
        }
 }