]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
gfs2: Don't clear sb->s_fs_info in gfs2_sys_fs_add
authorAndrew Price <anprice@redhat.com>
Wed, 28 May 2025 15:02:37 +0000 (16:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jun 2025 13:32:37 +0000 (15:32 +0200)
commitda728507b071c4ea006383a9c796cea1c4dab8a1
tree3d2db6b4f3da3b6eb86bcc321823dc6bff3fa175
parentab20b0bdb01fc3e65ff6273893c94013f3e8a0e5
gfs2: Don't clear sb->s_fs_info in gfs2_sys_fs_add

commit 9126d2754c5e5d1818765811a10af0a14cf1fa0a upstream.

When gfs2_sys_fs_add() fails, it sets sb->s_fs_info to NULL on its error
path (see commit 0d515210b696 ("GFS2: Add kobject release method")).
The intention seems to be to prevent dereferencing sb->s_fs_info once
the object pointed to has been deallocated, but that would be better
achieved by setting the pointer to NULL in free_sbd().

As a consequence, when the call to gfs2_sys_fs_add() fails in
gfs2_fill_super(), sdp = GFS2_SB(inode) will evaluate to NULL in iput()
-> gfs2_drop_inode(), and accessing sdp->sd_flags will be a NULL pointer
dereference.

Fix that by only setting sb->s_fs_info to NULL when actually freeing the
object pointed to in free_sbd().

Fixes: ae9f3bd8259a ("gfs2: replace sd_aspace with sd_inode")
Reported-by: syzbot+b12826218502df019f9d@syzkaller.appspotmail.com
Signed-off-by: Andrew Price <anprice@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/gfs2/ops_fstype.c
fs/gfs2/sys.c