[CRIU] [PATCH] tmpfs: don't try to dump mountpoint at 0 fd

Tycho Andersen tycho.andersen at canonical.com
Thu Jan 21 18:39:36 PST 2016


On Jan 21, 2016 7:27 PM, "Andrew Vagin" <avagin at virtuozzo.com> wrote:
>
> On Tue, Jan 19, 2016 at 09:15:05AM -0700, Tycho Andersen wrote:
> > If we happen to get 0 as the fd for the mountpoint, there is an error:
> >
> > (00.280617) Dumping task cwd id 0x2b root id 0x2b
> > (00.280697) mnt: Dumping mountpoints
> > (00.280702) mnt:        132: 34:/ @ ./run/lock
> > (00.280714) mnt: Path `/run/lock' resolved to `./run/lock' mountpoint
> > tar: /proc/self/fd/0: Cannot open: Not a directory
> > tar: Error is not recoverable: exiting now
> > (00.283581) Error (util.c:666): exited, status=2
> > (00.283598) Error (mount.c:1220): mnt: Can't dump tmpfs content
> >
> > Instead, let's not ever use 0 as the mountpoint fd.
> >
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > ---
> >  mount.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/mount.c b/mount.c
> > index 9d5667a..ae7bfae 100644
> > --- a/mount.c
> > +++ b/mount.c
> > @@ -1190,6 +1190,13 @@ static int tmpfs_dump(struct mount_info *pm)
> >       if (fd < 0)
> >               return -1;
> >
> > +     /* if fd happens to be 0 here, we need to move it to something
> > +      * non-zero, because cr_system_userns closes STDIN_FILENO as we
are not
> > +      * interested in passing stdin to tar.
> > +      */
> > +     if (move_img_fd(&fd, STDIN_FILENO) < 0)
> > +             goto out;
>
> Should we handle a case when fd is equal to STDOUT_FILENO or
> STDERR_FILENO?

Yes, I think so. I was thinking initially since we don't close them that it
would be okay, but since we move them as well and potentially put the log
fd in place, we could get the same problem.

I'll see about sending a patch soon, thanks.

Tycho

> > +
> >       if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) & ~FD_CLOEXEC) == -1) {
> >               pr_perror("Can not drop FD_CLOEXEC");
> >               goto out;
> > --
> > 2.7.0.rc3
> >
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20160121/0814d113/attachment.html>


More information about the CRIU mailing list