[CRIU] [PATCH 02/15] namespaces: Make sure we're not getting stripped inode value

Andrey Vagin avagin at virtuozzo.com
Thu Oct 26 00:38:27 MSK 2017


On Wed, Oct 25, 2017 at 11:39:27AM +0300, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  criu/include/namespaces.h | 6 ++++++
>  criu/namespaces.c         | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
> index ef6083c9a944..dab7c84e1a23 100644
> --- a/criu/include/namespaces.h
> +++ b/criu/include/namespaces.h
> @@ -98,6 +98,12 @@ struct net_link {
>  	struct list_head	node;
>  };
>  
> +/*
> + * While kernel uses long numbers for ns
> + * enumeration, we don't plan to support
> + * that many namespaces, thus int numbers
> + * are used.
> + */
>  struct ns_id {
>  	unsigned int kid;
>  	unsigned int id;
> diff --git a/criu/namespaces.c b/criu/namespaces.c
> index 5c46976410e4..d31983a32ed0 100644
> --- a/criu/namespaces.c
> +++ b/criu/namespaces.c
> @@ -484,6 +484,7 @@ static unsigned int __get_ns_id(int pid, struct ns_desc *nd, bool alternative,
>  		return 0;
>  	}
>  	kid = st.st_ino;
> +	BUG_ON((unsigned long)st.st_ino > (unsigned long)(UINT_MAX));

Can we just return an error in this case? BUG() has to be used only for
impossible cases. This case is depended from a kernel and it is possible
in a future. I this an error with a good message will be more
informative...

>  	BUG_ON(!kid);
>  
>  out:
> -- 
> 2.7.5
> 


More information about the CRIU mailing list