[CRIU] [PATCH v2 03/15] sysctl: add req->has to mark successful sysctl_op request

Pavel Emelyanov xemul at virtuozzo.com
Thu Apr 21 07:09:52 PDT 2016


On 04/20/2016 05:42 PM, Pavel Tikhomirov wrote:
> must be carefull allocating memory for sysctl_req as trash values
> can cause segmentation fault
> 
> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
> ---
>  criu/include/sysctl.h | 1 +
>  criu/sysctl.c         | 8 ++++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/criu/include/sysctl.h b/criu/include/sysctl.h
> index b949a40..9ee93c6 100644
> --- a/criu/include/sysctl.h
> +++ b/criu/include/sysctl.h
> @@ -6,6 +6,7 @@ struct sysctl_req {
>  	void	*arg;
>  	int	type;
>  	int	flags;
> +	int	*has;

I'd better report back some bit (in case of sysctl was missing) in the flags field.

>  };
>  
>  extern int sysctl_op(struct sysctl_req *req, size_t nr_req, int op, unsigned int ns);
> diff --git a/criu/sysctl.c b/criu/sysctl.c
> index 21ae4ce..bd584bd 100644
> --- a/criu/sysctl.c
> +++ b/criu/sysctl.c
> @@ -261,6 +261,10 @@ static int __userns_sysctl_op(void *arg, int proc_fd, pid_t pid)
>  			goto out;
>  		}
>  
> +		if (req->has)
> +			/* sysctl in question exists */
> +			*req->has = 1;
> +
>  		/* save a pointer to the req, so we don't need to recompute its
>  		 * location
>  		 */
> @@ -371,6 +375,10 @@ static int __nonuserns_sysctl_op(struct sysctl_req *req, size_t nr_req, int op)
>  			goto out;
>  		}
>  
> +		if (req->has)
> +			/* sysctl in question exists */
> +			 *req->has = 1;
> +
>  		ret = do_sysctl_op(fd, req, op);
>  		if (ret)
>  			goto out;
> 



More information about the CRIU mailing list