Commit 0420e099 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

tmpfs: don't try to dump mountpoint at 0 fd

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: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent eec66f3d
...@@ -1190,6 +1190,13 @@ static int tmpfs_dump(struct mount_info *pm) ...@@ -1190,6 +1190,13 @@ static int tmpfs_dump(struct mount_info *pm)
if (fd < 0) if (fd < 0)
return -1; 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;
if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) & ~FD_CLOEXEC) == -1) { if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) & ~FD_CLOEXEC) == -1) {
pr_perror("Can not drop FD_CLOEXEC"); pr_perror("Can not drop FD_CLOEXEC");
goto out; goto out;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment