Commit Graph

14 Commits

Author SHA1 Message Date
Kir Kolyshkin 4249d94d76 chroot: fix unused warnings
When running golangci-lint run --tests=false, it complains:

> chroot/seccomp.go:15:7: const `seccompAvailable` is unused (unused)
> const seccompAvailable = true
>       ^
> chroot/seccomp.go:182:6: func `setupSeccomp` is unused (unused)
> func setupSeccomp(spec *specs.Spec, seccompProfilePath string) error {
>      ^

Fix this.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07:00
Kir Kolyshkin 24da18800e *: fix build tags
This change is generated by `go1.23rc2 fix ./...`.

Had to use go1.23rc2, since all released go versions have a bug
preventing it from working with `go 1.22.0` in go.mod (opened
https://github.com/golang/go/issues/68825,
https://github.com/golang/go/issues/68824 for awareness).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-09 17:05:30 -07:00
Nalin Dahyabhai 2a3a956cbb chroot.setupChrootBindMounts: pay more attention to flags
Pay better attention to dev/nodev/exec/noexec/suid/nosuid/ro/rw flags on
bind, overlay, and tmpfs mounts when any of them are specified.  Stop
quietly adding "nodev" when it isn't asked for.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-10-20 09:46:58 -04:00
Michal Biesek 5643a7fa8c
chroot: `setSeccomp` add support for `ArchPARISC(64)` and `ArchRISCV64`
Signed-off-by: Michal Biesek <michalbiesek@gmail.com>
2023-08-17 09:11:16 +02:00
Chris Evich 46eea31588
Replace io/ioutil calls with os calls
In golang 1.19, `io/ioutil` is fully deprecated preventing Buildah from
compiling.  Replace all calls with equivalent calls from the `os`
package.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-12-06 14:29:32 -05:00
Daniel J Walsh 8d5d763213
Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-19 07:11:44 -04:00
Giuseppe Scrivano 9445aa12ad
chroot: honor DefaultErrnoRet
honor the default errno ret value specified for the seccomp profile.

[NO NEW TESTS NEEDED]

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-07-08 10:51:12 +02:00
Sascha Grunert ce384684c0
Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 11:41:47 +02:00
dependabot[bot] 8bbe7a6066
build(deps): bump github.com/opencontainers/runc from 1.1.2 to 1.1.3
[NO NEW TESTS NEEDED]

Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.2 to 1.1.3.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/v1.1.3/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.2...v1.1.3)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-06-09 09:33:00 -04:00
Nalin Dahyabhai 81f2af5021
chroot: don't use the generate default seccomp filter for unit tests
When we link our test helper statically using the external linker, the
hardwired default seccomp filter we get from the runtime-tools generator
triggers a hang in it at startup.

Rather than switch to the internal linker, which seems to work around
this, start using the same seccomp filter for unit tests that we
actually use in real life, leaving analysis of which difference between
the two is responsible for it for another day.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-11-18 14:07:50 -05:00
Nalin Dahyabhai ecb40a48b4 chroot: fix handling of errno seccomp rules
When converting seccomp rules from the runtime spec to the structure
that we can feed to libseccomp, combine the prescribed errno value with
the action when we're mapping the "return an errno" action from one to
the other.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-09-23 18:06:58 -04:00
Nalin Dahyabhai 1033abccb7 chroot: handle slightly broken seccomp defaults
When a seccomp rule includes multiple equality checks for the same
argument for a syscall, they can never ALL be satisfied.  Because that's
how they're supposed to be treated, libseccomp returns an error when we
try to add them as part of the same conditional rule.  Try to detect
this exact case, and if we detect it, treat each condition as its own
rule.

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

Closes: #2105
Approved by: rhatdan
2020-01-28 21:16:07 +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 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