[CRIU] [PATCH 4/6] kdat: Make sure we're readin cache from tmpfs

Pavel Emelyanov xemul at virtuozzo.com
Thu Apr 5 10:57:57 MSK 2018


On 04/03/2018 08:46 PM, Cyrill Gorcunov wrote:
> When we're saving kdat we check if fs is laying on
> is on tmpfs thus on machine reboot it get removed
> and regenerated on next run. Still there is no
> proof that when we're reading it the underlied
> fs has not been changed. Lets add this check.

Can you describe the scenario in which kdat.cache writing happened on tmpfs, while
reading on non-tmpfs?

> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
>  criu/kerndat.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/criu/kerndat.c b/criu/kerndat.c
> index 798cb16274e4..227d429f9dde 100644
> --- a/criu/kerndat.c
> +++ b/criu/kerndat.c
> @@ -840,6 +840,7 @@ static int kerndat_x86_has_ptrace_fpu_xsave_bug(void)
>  
>  static int kerndat_try_load_cache(void)
>  {
> +	struct statfs s;
>  	int fd, ret;
>  
>  	fd = open(KERNDAT_CACHE_FILE, O_RDONLY);
> @@ -855,6 +856,12 @@ static int kerndat_try_load_cache(void)
>  		return -1;
>  	}
>  
> +	if (fstatfs(fd, &s) < 0 || s.f_type != TMPFS_MAGIC) {
> +		pr_warn("Can't read kdat cache from non-tempfs\n");
> +		close(fd);
> +		return -1;
> +	}
> +
>  	close(fd);
>  
>  	if (ret != sizeof(kdat) ||
> 



More information about the CRIU mailing list