Re: [PATCH 5/7] mkfs: properly fix TOCTOU open/stat race in config file handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 12, 2018 at 02:31:21PM -0500, Eric Sandeen wrote:
> After open of the configfile, simply fstat() that fd to ensure that
> we are checking the file we just opened, not something that got
> renamed in between.
> 
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxxx>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

--D

> ---
>  mkfs/config.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mkfs/config.c b/mkfs/config.c
> index f27e480..940a055 100644
> --- a/mkfs/config.c
> +++ b/mkfs/config.c
> @@ -550,7 +550,7 @@ open_cli_config(
>  		if (fd < 0)
>  			goto out;
>  
> -		ret = fstatat(dirfd, cli_config_file, &st, AT_SYMLINK_NOFOLLOW);
> +		ret = fstat(fd, &st);
>  		if (ret != 0)
>  			goto err_out_close;
>  
> @@ -563,7 +563,7 @@ open_cli_config(
>  
>  	memcpy(*fpath, cli_config_file, strlen(cli_config_file));
>  
> -	ret = fstatat(AT_FDCWD, cli_config_file, &st, AT_SYMLINK_NOFOLLOW);
> +	ret = fstat(fd, &st);
>  	if (ret != 0)
>  		goto err_out_close;
>  
> @@ -593,7 +593,7 @@ int
>  open_config_file(
>  	const char			*cli_config_file,
>  	struct mkfs_default_params	*dft,
> -	char				**fpath)
> +	char				**fpath)	/* path where config is found */
>  {
>  	int				dirfd, fd = -1, len, ret;
>  	struct stat			st;
> @@ -628,7 +628,7 @@ open_config_file(
>  		goto err_out_close;
>  	}
>  
> -	ret = fstatat(dirfd, "default", &st, AT_SYMLINK_NOFOLLOW);
> +	ret = fstat(fd, &st);
>  	if (ret != 0)
>  		goto err_out_close;
>  
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux