Skip to content

Use pivot_root instead of chroot for chrootarchive#22506

Merged
unclejack merged 1 commit intomoby:masterfrom
cpuguy83:no_chroot
May 6, 2016
Merged

Use pivot_root instead of chroot for chrootarchive#22506
unclejack merged 1 commit intomoby:masterfrom
cpuguy83:no_chroot

Conversation

@cpuguy83
Copy link
Member

@cpuguy83 cpuguy83 commented May 4, 2016

- What I did
Make chrootarchive default to using pivot_root instead of chroot

This fixes one issue with Docker running under a grsec kernel, which
denies chmod and mknod under chroot.

Note, if pivot_root fails it will still fallback to chroot.

- How to verify it
Run chrootarchive tests (may want to disable fallback to chroot to really verify that the pivot code works)

- A picture of a cute animal (not mandatory but encouraged)

Related to #20303

@cpuguy83
Copy link
Member Author

cpuguy83 commented May 4, 2016

ping @ncopa @justincormack

@unclejack
Copy link
Contributor

@cpuguy83 Perhaps it might be a good idea to change its name from chrootarchive to something better now. isolatedarchive, containedarchive or something along those lines would make it an adequate name for other platforms as well. It was named chrootarchive because Docker was Linux only at the time and it was also the only platform using that code.

Should we also keep the old chroot code for unix platforms (e.g. !linux) to make it easier in the future?

I'll be trying this out shortly.

@cpuguy83
Copy link
Member Author

cpuguy83 commented May 4, 2016

@unclejack It's kept under chroot_unix.go

@unclejack
Copy link
Contributor

@cpuguy83 I'm sorry, I've missed that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be also mounted at this point, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

This fixes one issue with Docker running under a grsec kernel, which
denies chmod and mknod under chroot.

Note, if pivot_root fails it will still fallback to chroot.

Signed-off-by: Brian Goff <[email protected]>
@LK4D4
Copy link
Contributor

LK4D4 commented May 6, 2016

LGTM

@thaJeztah
Copy link
Member

ping @unclejack PTAL

@unclejack
Copy link
Contributor

LGTM

}
mounted = false

return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this be return to return cleanup error if there was one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justincormack Which errors are you referring to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return and return nil would do the same thing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah sorry its late ignore me

@justincormack
Copy link
Contributor

LGTM

@unclejack unclejack merged commit eb52730 into moby:master May 6, 2016
@cpuguy83 cpuguy83 deleted the no_chroot branch May 7, 2016 00:39
@runcom
Copy link
Member

runcom commented May 8, 2016

getting

Sending build context to Docker daemon   196 MB
Error response from daemon: Untar re-exec error: exit status 1: output: Error cleaning up after pivot: remove /var/lib/docker/tmp/docker-builder113372687/.pivot_root936443744: no such file or directory

@runcom
Copy link
Member

runcom commented May 8, 2016

Filled #22587

runcom added a commit to runcom/docker that referenced this pull request May 9, 2016
The path we're trying to remove doesn't exist after a successful
chroot+chdir because a / is only appended after pivot_root is
successful and so we can't cleanup anymore with the old path.
Also fix leaking .pivot_root dirs under /var/lib/docker/tmp/docker-builder*
on error.

Fix moby#22587
Introduced by moby#22506

Signed-off-by: Antonio Murdaca <[email protected]>
dmcgowan pushed a commit to moby/go-archive that referenced this pull request Apr 3, 2025
The path we're trying to remove doesn't exist after a successful
chroot+chdir because a / is only appended after pivot_root is
successful and so we can't cleanup anymore with the old path.
Also fix leaking .pivot_root dirs under /var/lib/docker/tmp/docker-builder*
on error.

Fix moby/moby#22587
Introduced by moby/moby#22506

Signed-off-by: Antonio Murdaca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants