linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: fix use after free in closedir
@ 2020-11-27 10:15 Huang Jianan
  2020-11-27 10:46 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Huang Jianan @ 2020-11-27 10:15 UTC (permalink / raw)
  To: linux-erofs; +Cc: liufeibao, guoweichao, zhangshiming

No need to closedir _dir again since it has been released.

Signed-off-by: Huang Jianan <huangjianan@oppo.com>
Signed-off-by: Guo Weichao <guoweichao@oppo.com>
---
 lib/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index eb2e0f2..2397bc7 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -958,11 +958,11 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
 
 	ret = erofs_prepare_dir_file(dir);
 	if (ret)
-		goto err_closedir;
+		goto err;
 
 	ret = erofs_prepare_inode_buffer(dir);
 	if (ret)
-		goto err_closedir;
+		goto err;
 
 	if (IS_ROOT(dir))
 		erofs_fixup_meta_blkaddr(dir);
@@ -1003,6 +1003,7 @@ fail:
 
 err_closedir:
 	closedir(_dir);
+err:
 	return ERR_PTR(ret);
 }
 
-- 
2.25.1


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

* Re: [PATCH] erofs-utils: fix use after free in closedir
  2020-11-27 10:15 [PATCH] erofs-utils: fix use after free in closedir Huang Jianan
@ 2020-11-27 10:46 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2020-11-27 10:46 UTC (permalink / raw)
  To: Huang Jianan; +Cc: liufeibao, guoweichao, linux-erofs, zhangshiming

Hi Jianan,

On Fri, Nov 27, 2020 at 06:15:11PM +0800, Huang Jianan wrote:
> No need to closedir _dir again since it has been released.
> 
> Signed-off-by: Huang Jianan <huangjianan@oppo.com>
> Signed-off-by: Guo Weichao <guoweichao@oppo.com>
> ---
>  lib/inode.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index eb2e0f2..2397bc7 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -958,11 +958,11 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
>  
>  	ret = erofs_prepare_dir_file(dir);
>  	if (ret)
> -		goto err_closedir;
> +		goto err;
>  
>  	ret = erofs_prepare_inode_buffer(dir);
>  	if (ret)
> -		goto err_closedir;
> +		goto err;

Thanks for finding this, after looking into the current dev branch,
I think

		if (IS_ERR(d->inode)) {
			ret = PTR_ERR(d->inode);
fail:
			d->inode = NULL;
			d->type = EROFS_FT_UNKNOWN;
			goto err_closedir;
		}

needs to be fixed as well.
You could fix it or I can also send the next version about this
if needed.


Thanks,
Gao Xiang

>  
>  	if (IS_ROOT(dir))
>  		erofs_fixup_meta_blkaddr(dir);
> @@ -1003,6 +1003,7 @@ fail:
>  
>  err_closedir:
>  	closedir(_dir);
> +err:
>  	return ERR_PTR(ret);
>  }
>  
> -- 
> 2.25.1
> 


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

end of thread, other threads:[~2020-11-27 10:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27 10:15 [PATCH] erofs-utils: fix use after free in closedir Huang Jianan
2020-11-27 10:46 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).