Commit Graph

11513 Commits

Author SHA1 Message Date
Christian Brauner
ea4fd7f853
start: record inherited namespaces earlier to make it available for idmapped rootfs setup
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-25 18:12:27 -04:00
Christian Brauner
e74fd55bcb
start: don't overwrite file descriptors during namespace preservation
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-25 18:12:26 -04:00
Christian Brauner
dcfd75bb41
conf: log file descriptors on error during idmapped mount setup
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-25 18:12:23 -04:00
Marc E. Fiuczynski
c3e648700d
fix for issue 4026: set broadcast to 0.0.0.0 for /31 and /32
Signed-off-by: Marc E. Fiuczynski <mfiuczyn@akamai.com>
2022-07-25 18:12:21 -04:00
Serge Hallyn
cfcbdb75f0
use systemd dbus StartTransientUnit for unpriv cgroup2
If, when init'ing cgroups for a container start, we detect that we
are an unprivileged user on a unified-hierarchy-only system, then we
try to request systemd, through dbus api, to create a new scope for
us with delegation.  Call the cgroup it creates for us P1.  We then
create P1/init, move ourselves into there, so we can enable the
controllers for delegation to P1's children through P1/cgroup.subtree_control.

On attach, we try to request systemd attach us to the container's
scope.  We can't do that ourselves in the normal case, as root owns
our login cgroups.

Create a new command api for the lxc monitor to tell lxc-attach the
systemd scope to which to attach.

Changelog:
 * free cgroup_meta.systemd_scope in lxc_conf_free (Thanks Tycho)
 * fix some indent
 * address some (not all) of brauner's feedback

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2022-07-25 18:12:19 -04:00
Raphael Isemann
28726f2150
Fix uninitialized read in parse_cap when libcap is not used
fuzz-lxc-cgroup-init currently fails for me with the input
```
 lxc.cap.keep=0
```

with this report:

```
==640655==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x833c77 in parse_cap /src/lxc/san_build/../src/lxc/conf.c:3161:6
    #1 0xaa5fd6 in add_cap_entry /src/lxc/san_build/../src/lxc/confile.c:2462:9
    #2 0x9eb69c in set_config_cap_keep /src/lxc/san_build/../src/lxc/confile.c:2503:8
    #3 0x974a76 in parse_line /src/lxc/san_build/../src/lxc/confile.c:3115:9
    #4 0xea8cac in lxc_file_for_each_line_mmap /src/lxc/san_build/../src/lxc/parse.c:123:9
    #5 0x9700a1 in lxc_config_read /src/lxc/san_build/../src/lxc/confile.c:3192:9
    #6 0x4a3b50 in LLVMFuzzerTestOneInput /src/lxc/san_build/../src/tests/fuzz-lxc-cgroup-init.c:40:8
    #7 0x10556e3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #8 0x1041372 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:324:6
    #9 0x1046bbc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:860:9
    #10 0x106f7b2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #11 0x7ffff7bc00b2 in __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:308:16
    #12 0x420a9d in _start (/home/fuzzer/oss-fuzz/build/out/lxc/fuzz-lxc-cgroup-init+0x420a9d)

  Uninitialized value was created by an allocation of 'last_cap' in the stack frame of function 'parse_cap'
    #0 0x832e30 in parse_cap /src/lxc/san_build/../src/lxc/conf.c:3131
```

The reason is that without libcap we parse_cap ends up comparing two
uninitialized values. See the snippet below:

```
int parse_cap(const char *cap_name, __u32 *cap)
{
	int ret;
	unsigned int res;
	__u32 last_cap;

  [...]

	ret = lxc_caps_last_cap(&last_cap); // NOTE: 1. Call here.
	if (ret) // Not taken as dummy lxc_caps_last_cap returned 0.
		return -1;

	if ((__u32)res > last_cap) // last_cap is uninitialized.
		return -1;

	*cap = (__u32)res;
	return 0;
}
```

Root cause seems to be that the dummy `lxc_caps_last_cap` returns 0 but
doesn't set the last_cap value. This patch just returns -1 as an error code
to avoid the uninitialized read.

Note: When reproducing the bug you need to compile with O0 and *not* with O1
otherwise you will not see the report.

Signed-off-by: Raphael Isemann <teemperor@gmail.com>
2022-07-25 18:12:16 -04:00
Petr Malat
d663495eeb
meson: Generate compile commands by iterating over an array
This makes it possible to add a new command without updating multiple
places in the meson file.

Signed-off-by: Petr Malat <oss@malat.biz>
2022-07-25 18:12:08 -04:00
Stéphane Graber
1f8c355727
Release LXC 5.0.0
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-16 16:40:04 -04:00
Stéphane Graber
dcde35e709
Merge pull request #4148 from stgraber/master
meson: Fix bad strerror_r check
2022-06-13 22:17:52 -04:00
Stéphane Graber
9fea612230
meson: Fix bad strerror_r check
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-13 21:27:46 -04:00
Stéphane Graber
527281dacc
Merge pull request #4146 from brauner/2022-06-13.fixes
build: fixes
2022-06-13 10:12:07 -04:00
Christian Brauner
57f4bd73cb
build: map autotools options to meson options in meson_options.txt
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 15:46:33 +02:00
Christian Brauner
00b9b120af
README: reflect meson in the documentation
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 15:36:13 +02:00
Christian Brauner
493bf2ded8
build: add missing memfd-rexec option
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 15:33:36 +02:00
Christian Brauner
0c4549a331
build: support thread-safety enforcement as option
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 15:33:31 +02:00
Christian Brauner
de4543d8f8
build: use cc.links() to check for static libcap
Fixes: #4144
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-13 11:04:17 +02:00
Stéphane Graber
f5420c9d3f
Merge pull request #4142 from brauner/2022-06-09.build.fixes
tests: fix oss-fuzz port to meson
2022-06-09 17:35:34 -04:00
Christian Brauner
3952fb4588
oss-fuzz: cleanup build flags
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:08 +02:00
Christian Brauner
8f7ba7c8bc
oss-fuzz: ensure binaries are zipped
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:08 +02:00
Christian Brauner
cfa85da6da
oss-fuzz: adapt options to oss-fuzz build
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:08 +02:00
Christian Brauner
0196c4df71
oss-fuzz: handle dependencies
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:08 +02:00
Christian Brauner
9fec9fef72
build: separate oss-fuzz tests from regular test builds
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:08 +02:00
Christian Brauner
a8e5f3623e
github/workflows/cifuzz: update to Ubuntu 22.04
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
d42a3b1366
build: add oss-fuzz switch
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
0b9adfdad4
build: add seccomp build option
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
826391b2a2
build: fix build with various options turned off
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Christian Brauner
abc5e6bb94
build: tweak build flags
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-09 23:07:07 +02:00
Stéphane Graber
31c831dfe4
Merge pull request #4141 from lxc/dependabot/github_actions/actions/upload-artifact-3
build(deps): bump actions/upload-artifact from 1 to 3
2022-06-09 02:02:41 -04:00
dependabot[bot]
cb3178a604
build(deps): bump actions/upload-artifact from 1 to 3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 1 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v1...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-09 06:01:55 +00:00
Stéphane Graber
706b3f2d0a
Merge pull request #4140 from turrisxyz/Dependabot-GitHub-Actions
chore: Included githubactions in the dependabot config
2022-06-09 02:01:31 -04:00
naveen
7ceb9b99ba chore: Included githubactions in the dependabot config
This should help with keeping the GitHub actions updated on new releases. This will also help with keeping it secure.

Dependabot helps in keeping the supply chain secure https://docs.github.com/en/code-security/dependabot

GitHub actions up to date https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot

https://github.com/ossf/scorecard/blob/main/docs/checks.md#dependency-update-tool
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
2022-06-09 01:29:39 +00:00
Christian Brauner
46341a7598
Merge pull request #4139 from stgraber/master
Github workflow fixes
2022-06-09 00:46:28 +02:00
Stéphane Graber
554060879b
github: Fix compiler version task for coverity
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-08 17:46:50 -04:00
Stéphane Graber
59d1841165
github: Fix bad syntax in cifuzz
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-08 17:44:08 -04:00
Christian Brauner
0f8c8f89b3
Merge pull request #4137 from brauner/2022-06-08.stgraber.master
build: remove autotools and finish meson port
2022-06-08 20:43:10 +02:00
Christian Brauner
b4b1f1498c
github/workflows/sanitizers: port sanitizers builds to meson
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:15:07 +02:00
Christian Brauner
0ab1a63461
github/workflows: port all workflows to Ubuntu 22.04
So we have a new enough meson version everywhere.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:15:07 +02:00
Christian Brauner
272f1ee460
github/workflows/cifuzz: ensure necessary paths are added
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:15:07 +02:00
Christian Brauner
2fb1430b3f
github/workflows/build: remove sanitizer build
We have a separate workflow for this.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:15:07 +02:00
Christian Brauner
77b2a6c405
github/workflows/build: add -Db_lto_mode=default
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:15:07 +02:00
Christian Brauner
47991ce753
github/workflows/build: install lvvm as well
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:15:07 +02:00
Christian Brauner
b8b31ab36a
oss-fuzz: more meson options
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:15:07 +02:00
Christian Brauner
d679f7d85f
build: lxc-init doesn't need to build the whole config infra
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:03:59 +02:00
Christian Brauner
575d0e34ae
build: add additional command line switches
In order to compile for fuzzers where we will need and want to turn a
bunch of things off add command line switches that allow us to do so.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:03:05 +02:00
Christian Brauner
5b726537aa
build: use liblxc_sources everywhere
The old split didn't buy us a lot and causes problems when buidling with
sanitizers enabled so just use the full sources.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 20:01:26 +02:00
Christian Brauner
6bb8d4ce31
config: make lxc-{containers,net}.in executable
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-08 18:52:14 +02:00
Stéphane Graber
bb97e07995
Merge pull request #4136 from turrisxyz/Pinned-Dependencies-GitHub
chore: Set permissions for GitHub actions
2022-06-08 01:26:59 -04:00
Stéphane Graber
cd3d65155b
meson: Always defined IS_BIONIC
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-08 01:00:51 -04:00
Stéphane Graber
6ae86a9c17
src: Don't use ifdef/defined for config.h
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-08 00:47:05 -04:00
Stéphane Graber
9c3a240bef
github: Update coverity workflow for meson
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-08 00:47:04 -04:00