[CRIU] [PATCH] restore: use /proc/self/mountinfo for collecting mounts fo the root task (v3)
Tycho Andersen
tycho.andersen at canonical.com
Fri Aug 8 07:41:16 PDT 2014
On Fri, Aug 08, 2014 at 03:02:06PM +0400, Andrey Vagin wrote:
> If the root task is forked in a new pidns, it can't use its pid for
> accessing /proc, because this proc belongs to the source pidns.
>
> v2: don't copy a static string.
> v3: take a bright part of Tycho's patch
>
> Reported-by: Tycho Andersen <tycho.andersen at canonical.com>
> Cc: Tycho Andersen <tycho.andersen at canonical.com>
Acked-by: Tycho Andersen <tycho.andersen at canonical.com>
Tycho
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> mount.c | 2 +-
> proc_parse.c | 3 +--
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/mount.c b/mount.c
> index e0e88ea..3287282 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -1911,7 +1911,7 @@ int prepare_mnt_ns(void)
> {
> int ret = -1;
> struct mount_info *mis, *old;
> - struct ns_id ns = { .pid = getpid(), .nd = &mnt_ns_desc };
> + struct ns_id ns = { .pid = PROC_SELF, .nd = &mnt_ns_desc };
>
> if (!(root_ns_mask & CLONE_NEWNS))
> return rst_collect_local_mntns();
> diff --git a/proc_parse.c b/proc_parse.c
> index 66a1e12..271d46b 100644
> --- a/proc_parse.c
> +++ b/proc_parse.c
> @@ -944,8 +944,7 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid)
> FILE *f;
> char str[1024];
>
> - snprintf(str, sizeof(str), "/proc/%d/mountinfo", pid);
> - f = fopen(str, "r");
> + f = fopen_proc(pid, "mountinfo");
> if (!f) {
> pr_perror("Can't open %d mountinfo", pid);
> return NULL;
> --
> 1.9.3
>
More information about the CRIU
mailing list