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