All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
@ 2018-10-08 11:56 Andrew Price
  2018-10-08 20:10 ` Bob Peterson
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Price @ 2018-10-08 11:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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().

Reported-by: syzbot+dcb8b3587445007f5808 at syzkaller.appspotmail.com
Signed-off-by: Andrew Price <anprice@redhat.com>
---
 fs/gfs2/ops_fstype.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index c2469833b4fb..4ec69d9783a8 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -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);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH] gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
  2018-10-08 11:56 [Cluster-devel] [PATCH] gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd Andrew Price
@ 2018-10-08 20:10 ` Bob Peterson
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Peterson @ 2018-10-08 20:10 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> 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().
> 
> Reported-by: syzbot+dcb8b3587445007f5808 at syzkaller.appspotmail.com
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-08 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 11:56 [Cluster-devel] [PATCH] gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd Andrew Price
2018-10-08 20:10 ` Bob Peterson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.