gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
PATCH 1/1 gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
When alloc_percpu() fails, sdp gets freed but sb->s_fs_info still points to the same address. Move the assignment after that error check so that s_fs_info can only point to a valid sdp or NULL, which is checked for later in the error path, in gfs2_kill_super().
--- fs/gfs2/ops_fstype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/ops_fstype.c +1 -1
@@ -72,13 +72,13 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)if (!sdp)return NULL ; - sb->s_fs_info = sdp; sdp->sd_vfs = sb; sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats);if (!sdp->sd_lkstats) {kfree (sdp);return NULL ; } + sb->s_fs_info = sdp;set_bit (SDF_NOJOURNALID , &sdp->sd_flags);gfs2_tune_init (&sdp->sd_tune);
Signature · 1 line
2.17.1
PATCH 1/1 gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
----- Original Message -----
Quoted 8 lines
When
alloc_percpu()fails, sdp gets freed butsb->s_fs_infostill points to the same address. Move the assignment after that error check so thats_fs_infocan only point to a valid sdp or NULL, which is checked for later in the error path, ingfs2_kill_super().Reported-by syzbot+dcb8b3587445007f5808 at syzkaller.appspotmail.comSigned-off-by Andrew Price <[email protected]>---
Hi,
Thanks. This is now pushed to the for-next branch of the linux-gfs2 tree:
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=4c62bd9cea7bcf10292f7e4c57a2bca332942697
Regards,
Bob Peterson
Red Hat File Systems