]> git.ipfire.org Git - people/arne_f/kernel.git/commit
gfs2: clean up iopen glock mess in gfs2_create_inode
authorBob Peterson <rpeterso@redhat.com>
Tue, 19 Nov 2019 16:40:46 +0000 (11:40 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:12:30 +0000 (13:12 +0200)
commit13c66d2d2bf49422217b39561827e484344fc8fe
tree736732abb81233ce884b9cbdbb06a826ed30728e
parent87d2800e493f9b91857e078041ecc058bff9f3ef
gfs2: clean up iopen glock mess in gfs2_create_inode

[ Upstream commit 2c47c1be51fbded1f7baa2ceaed90f97932f79be ]

Before this patch, gfs2_create_inode had a use-after-free for the
iopen glock in some error paths because it did this:

gfs2_glock_put(io_gl);
fail_gunlock2:
if (io_gl)
clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);

In some cases, the io_gl was used for create and only had one
reference, so the glock might be freed before the clear_bit().
This patch tries to straighten it out by only jumping to the
error paths where iopen is properly set, and moving the
gfs2_glock_put after the clear_bit.

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/inode.c