* [Cluster-devel] [PATCH AUTOSEL 4.14 02/14] gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free [not found] <20201110035611.424867-1-sashal@kernel.org> @ 2020-11-10 3:55 ` Sasha Levin 2020-11-10 3:55 ` [Cluster-devel] [PATCH AUTOSEL 4.14 03/14] gfs2: Add missing truncate_inode_pages_final for sd_aspace Sasha Levin 2020-11-10 3:56 ` [Cluster-devel] [PATCH AUTOSEL 4.14 04/14] gfs2: check for live vs. read-only file system in gfs2_fitrim Sasha Levin 2 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2020-11-10 3:55 UTC (permalink / raw) To: cluster-devel.redhat.com From: Bob Peterson <rpeterso@redhat.com> [ Upstream commit d0f17d3883f1e3f085d38572c2ea8edbd5150172 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/gfs2/rgrp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 7cb0672294dfc..70a344d864447 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -720,9 +720,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); } } -- 2.27.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH AUTOSEL 4.14 03/14] gfs2: Add missing truncate_inode_pages_final for sd_aspace [not found] <20201110035611.424867-1-sashal@kernel.org> 2020-11-10 3:55 ` [Cluster-devel] [PATCH AUTOSEL 4.14 02/14] gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free Sasha Levin @ 2020-11-10 3:55 ` Sasha Levin 2020-11-10 3:56 ` [Cluster-devel] [PATCH AUTOSEL 4.14 04/14] gfs2: check for live vs. read-only file system in gfs2_fitrim Sasha Levin 2 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2020-11-10 3:55 UTC (permalink / raw) To: cluster-devel.redhat.com From: Bob Peterson <rpeterso@redhat.com> [ Upstream commit a9dd945ccef07a904e412f208f8de708a3d7159e ] Gfs2 creates an address space for its rgrps called sd_aspace, but it never called truncate_inode_pages_final on it. This confused vfs greatly which tried to reference the address space after gfs2 had freed the superblock that contained it. This patch adds a call to truncate_inode_pages_final for sd_aspace, thus avoiding the use-after-free. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/gfs2/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index c3f3f1ae4e1b7..639e2c86758a4 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -924,6 +924,7 @@ static void gfs2_put_super(struct super_block *sb) gfs2_jindex_free(sdp); /* Take apart glock structures and buffer lists */ gfs2_gl_hash_clear(sdp); + truncate_inode_pages_final(&sdp->sd_aspace); gfs2_delete_debugfs_file(sdp); /* Unmount the locking protocol */ gfs2_lm_unmount(sdp); -- 2.27.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH AUTOSEL 4.14 04/14] gfs2: check for live vs. read-only file system in gfs2_fitrim [not found] <20201110035611.424867-1-sashal@kernel.org> 2020-11-10 3:55 ` [Cluster-devel] [PATCH AUTOSEL 4.14 02/14] gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free Sasha Levin 2020-11-10 3:55 ` [Cluster-devel] [PATCH AUTOSEL 4.14 03/14] gfs2: Add missing truncate_inode_pages_final for sd_aspace Sasha Levin @ 2020-11-10 3:56 ` Sasha Levin 2 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2020-11-10 3:56 UTC (permalink / raw) To: cluster-devel.redhat.com From: Bob Peterson <rpeterso@redhat.com> [ Upstream commit c5c68724696e7d2f8db58a5fce3673208d35c485 ] Before this patch, gfs2_fitrim was not properly checking for a "live" file system. If the file system had something to trim and the file system was read-only (or spectator) it would start the trim, but when it starts the transaction, gfs2_trans_begin returns -EROFS (read-only file system) and it errors out. However, if the file system was already trimmed so there's no work to do, it never called gfs2_trans_begin. That code is bypassed so it never returns the error. Instead, it returns a good return code with 0 work. All this makes for inconsistent behavior: The same fstrim command can return -EROFS in one case and 0 in another. This tripped up xfstests generic/537 which reports the error as: +fstrim with unrecovered metadata just ate your filesystem This patch adds a check for a "live" (iow, active journal, iow, RW) file system, and if not, returns the error properly. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> --- fs/gfs2/rgrp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 70a344d864447..c4eb6a5fcea99 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1361,6 +1361,9 @@ int gfs2_fitrim(struct file *filp, void __user *argp) if (!capable(CAP_SYS_ADMIN)) return -EPERM; + if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) + return -EROFS; + if (!blk_queue_discard(q)) return -EOPNOTSUPP; -- 2.27.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-10 3:56 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20201110035611.424867-1-sashal@kernel.org> 2020-11-10 3:55 ` [Cluster-devel] [PATCH AUTOSEL 4.14 02/14] gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free Sasha Levin 2020-11-10 3:55 ` [Cluster-devel] [PATCH AUTOSEL 4.14 03/14] gfs2: Add missing truncate_inode_pages_final for sd_aspace Sasha Levin 2020-11-10 3:56 ` [Cluster-devel] [PATCH AUTOSEL 4.14 04/14] gfs2: check for live vs. read-only file system in gfs2_fitrim Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).