Commit Graph

117 Commits

Author SHA1 Message Date
Nalin Dahyabhai fa8653314a run: ignore EIO when flushing at the end, avoid double log
When reading the last of the output from a child process, ignore an EIO,
since we already got the HUP indication.

Avoid double-logging errors in our I/O loop when using isolation other
than chroot (spotted by @afbjorklund).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1273
Approved by: rhatdan
2019-01-12 12:04:54 +00:00
Daniel J Walsh 18309de5b7 Allow cgroups to be passed into chroot, read/only
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1130
Approved by: rhatdan
2018-11-16 02:34:55 +00:00
TomSweeneyRedHat aeac8e9647 Check for empty buildTime in version
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1107
Approved by: rhatdan
2018-10-19 12:46:52 +00:00
Nalin Dahyabhai 0a971ebeec chroot: set up seccomp and capabilities after supplemental groups
Move the setting of capabilites and the seccomp filter to after we've
set the supplemental groups list and set our primary GID.

Set capabilities after we set the seccomp filter, because we won't be
able to set a filter if we're dropping CAP_SYS_ADMIN.  Set them as the
very last thing before dropping to the runtime UID.  Leave CAP_SETUID in
if we're going to become an unprivileged user, so that we'll be allowed
to switch UIDs -- the capability will be dropped then anyway.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1069
Approved by: rhatdan
2018-10-05 13:03:02 +00:00
Nalin Dahyabhai 289c512c0d chroot: fix capabilities list setup and application
Correctly handle setting capabilities: the Clear() and Apply() methods
on the Capabilities interface take a bitmask of capability kinds, not
specific capability types.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1069
Approved by: rhatdan
2018-10-05 13:03:02 +00:00
Nalin Dahyabhai 0a8af543b2 chroot: only create user namespaces when we know we need them
When running with chroot isolation, only create a new user namespace
when we have mappings to set.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1069
Approved by: rhatdan
2018-10-05 13:03:02 +00:00
Daniel J Walsh ba012ddec6
Move buildah from projecatatomic/buildah to containers/buildah
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-09-18 08:06:11 -04:00
Nalin Dahyabhai 2358d51e74 chroot: create missing parent directories for volume mounts
When ensuring that the target for a volume mount is present, be sure to
create any leading directories which are also not yet present.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #997
Approved by: rhatdan
2018-09-14 14:11:39 +00:00
Nalin Dahyabhai e4ec46aaa0 stdin: on HUP, read everything
When we're polling to handle stdio for a container, when we detect a HUP
on our stdin, read all that we can from stdin before closing it, instead
of reading only, at most, a single chunk of bytes.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #980
Approved by: rhatdan
2018-09-04 20:08:20 +00:00
Nalin Dahyabhai 347478cccd chroot isolation: chroot() before setting up seccomp
Make the chroot() call before applying a seccomp filter, which might not
allow us to do it.  Add more debugging messages.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #979
Approved by: rhatdan
2018-08-31 13:46:10 +00:00
Nalin Dahyabhai 9175ccea84 chroot: correct a comment
We're specifying the MS_RDONLY flag, so don't suggest that we're doing a
read-write mount.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #923
Approved by: rhatdan
2018-08-10 15:45:26 +00:00
Nalin Dahyabhai ba23b7f106 chroot: bind mount an empty directory for masking
In chroot isolation, when we attempt to mask a directory, use a
read-only bind mount of an empty directory instead of a read-only mount
of a fresh tmpfs with size=0, which is more likely to be be denied by
mandatory access controls.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #923
Approved by: rhatdan
2018-08-10 15:45:26 +00:00
Daniel J Walsh 2cafe11229 unshare: make adjusting the OOM score optional
The OOM score adjustment is an optional field in the runtime spec, so
only try to set it if it's set in the spec.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #906
Approved by: rhatdan
2018-08-03 13:24:47 +00:00
Nalin Dahyabhai 35a37f36d3 chroot: handle raising process limits
When using chroot isolation, if we're configured to raise any process
limits above their current values, do so in the grandparent process,
before it transfers execution to a child that it starts in a user
namespace, which won't have the privileges to do so.

The child can still lower resource limits and set limits to the values
that it inherited, so let it continue to do so.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #891
Approved by: rhatdan
2018-08-03 09:02:08 +00:00
Nalin Dahyabhai 3160f5479e chroot: make the resource limits name map module-global
Move the resource limits name map out of the setRlimits() function, and
use it to set up a reverse of the same map in init().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #891
Approved by: rhatdan
2018-08-03 09:02:08 +00:00
Nalin Dahyabhai 8b9fc6e8b6 Set BUILDAH_ISOLATION=chroot when running unprivileged
When we're run by an unprivileged user, default to BUILDAH_ISOLATION=chroot.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #836
Approved by: rhatdan
2018-08-01 14:04:59 +00:00
Nalin Dahyabhai 38ef1231f2 Add and implement IsolationChroot
Add an IsolationChroot that trades flexibility and isolation for being
able to do what it does in a host environment that's already isolated to
the point where we're not allowed to set up some of that isolation,
producing a result that leans more toward chroot(1) than runc(1) does.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #836
Approved by: rhatdan
2018-08-01 14:04:59 +00:00