ceph: fix use-after-free for fsc->mdsc
diff mbox series

Message ID 20200723073225.340115-1-xiubli@redhat.com
State New
Headers show
Series
  • ceph: fix use-after-free for fsc->mdsc
Related show

Commit Message

Xiubo Li July 23, 2020, 7:32 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

If the ceph_mdsc_init() fails, it will free the mdsc already.

Reported-by: syzbot+b57f46d8d6ea51960b8c@syzkaller.appspotmail.com
URL: https://tracker.ceph.com/issues/46684
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/mds_client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jeff Layton July 23, 2020, 10:41 a.m. UTC | #1
On Thu, 2020-07-23 at 15:32 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
> 
> If the ceph_mdsc_init() fails, it will free the mdsc already.
> 
> Reported-by: syzbot+b57f46d8d6ea51960b8c@syzkaller.appspotmail.com
> URL: https://tracker.ceph.com/issues/46684
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>  fs/ceph/mds_client.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index af7221d1c610..590822fab767 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -4453,7 +4453,6 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
>  		goto err_mdsc;
>  	}
>  
> -	fsc->mdsc = mdsc;
>  	init_completion(&mdsc->safe_umount_waiters);
>  	init_waitqueue_head(&mdsc->session_close_wq);
>  	INIT_LIST_HEAD(&mdsc->waiting_for_map);
> @@ -4508,6 +4507,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
>  
>  	strscpy(mdsc->nodename, utsname()->nodename,
>  		sizeof(mdsc->nodename));
> +
> +	fsc->mdsc = mdsc;
>  	return 0;
>  
>  err_mdsmap:

Looks good, merged into testing.

Thanks!

Patch
diff mbox series

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index af7221d1c610..590822fab767 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -4453,7 +4453,6 @@  int ceph_mdsc_init(struct ceph_fs_client *fsc)
 		goto err_mdsc;
 	}
 
-	fsc->mdsc = mdsc;
 	init_completion(&mdsc->safe_umount_waiters);
 	init_waitqueue_head(&mdsc->session_close_wq);
 	INIT_LIST_HEAD(&mdsc->waiting_for_map);
@@ -4508,6 +4507,8 @@  int ceph_mdsc_init(struct ceph_fs_client *fsc)
 
 	strscpy(mdsc->nodename, utsname()->nodename,
 		sizeof(mdsc->nodename));
+
+	fsc->mdsc = mdsc;
 	return 0;
 
 err_mdsmap: