[CRIU] [PATCH] Guard against empty file lock status

Andrei Vagin avagin at gmail.com
Mon Oct 7 20:00:13 MSK 2019


Applied, thanks!

On Tue, Oct 01, 2019 at 08:56:26PM +0000, Nicolas Viennot wrote:
> The lock status string may be empty. This can happen when the owner of
> the lock is invisible from our PID namespace. This unfortunate behavior
> is fixed in kernels v4.19 and up (see commit 1cf8e5de40)
> 
> Signed-off-by: Nicolas Viennot <Nicolas.Viennot at twosigma.com>
> ---
>  criu/proc_parse.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/proc_parse.c b/criu/proc_parse.c
> index 97f82ee0..d67392a1 100644
> --- a/criu/proc_parse.c
> +++ b/criu/proc_parse.c
> @@ -1669,17 +1669,27 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type, void *arg)
>  		if (fdinfo_field(str, "lock")) {
>  			struct file_lock *fl;
>  			struct fdinfo_common *fdinfo = arg;
> +			char *flock_status = str+sizeof("lock:\t")-1;
>  
>  			if (type != FD_TYPES__UND)
>  				continue;
>  
> +			/*
> +			 * The lock status can be empty when the owner of the
> +			 * lock is invisible from our PID namespace.
> +			 * This unfortunate behavior is fixed in kernels v4.19
> +			 * and up (see commit 1cf8e5de40).
> +			 */
> +			if (flock_status[0] == '\0')
> +				continue;
> +
>  			fl = alloc_file_lock();
>  			if (!fl) {
>  				pr_perror("Alloc file lock failed!");
>  				goto out;
>  			}
>  
> -			if (parse_file_lock_buf(str + 6, fl, 0)) {
> +			if (parse_file_lock_buf(flock_status, fl, 0)) {
>  				xfree(fl);
>  				goto parse_err;
>  			}
> -- 
> 2.19.1
> 
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list