Commit Graph

11443 Commits

Author SHA1 Message Date
Đoàn Trần Công Danh
16ebb29dcc meson.build: allow explicit distrosysconfdir
Allows either:

- Build inside minimal-and-clean chroot with neither
  /etc/sysconfig nor /etc/default available.
- Cross Compile lxc from foreign distro,
  let's say host distro uses /etc/sysconfig and build distro
  uses /etc/default and vice versus.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
2022-08-10 07:12:44 +07:00
Christian Brauner
cbbb09b56f
Merge pull request #4175 from stgraber/master
gitignore: Simplify
2022-08-03 09:55:30 +02:00
Stéphane Graber
e452c89457
gitignore: Simplify
The move to meson has made it so that all rendered/built files are now
nicely self-contained. This lets us greatly simplify our gitignore,
effectively just ignoring release tarballs and the few usual temporary
files we may deal with during development.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-08-01 18:12:06 -04:00
Stéphane Graber
332667eb21
Merge pull request #4173 from brauner/2022-07-25.lxc-usernsexec
lxc-usernsexec: allow to select which {g,u}id to switch to
2022-07-25 17:22:24 -04:00
Christian Brauner
32a0715193
lxc-usernsexec: allow to select which {g,u}id to switch to
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-25 22:25:55 +02:00
Christian Brauner
7f66430711
README: update security mails
Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-19 10:29:41 +02:00
Christian Brauner
94997c0c40
Merge pull request #4168 from ffontaine/master
meson.build: fix build without stack-protector
2022-07-14 22:53:49 +01:00
Fabrice Fontaine
5e704fe389 meson.build: fix build without stack-protector
Move -fstack-protector-strong from possible_cc_flags to
possible_link_flags to avoid a build failure on toolchains without ssp

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-07-14 17:50:48 +02:00
Stéphane Graber
9a40624c82
Merge pull request #4167 from ffontaine/master
meson.build: fix build with -Dcapabilities=false
2022-07-14 11:45:37 -04:00
Fabrice Fontaine
7d72354898 meson.build: fix build with -Dcapabilities=false
Define libcap_static to an empty array to avoid the following build
failure with -Dcapabilities=false:

output/build/lxc-5.0.0/src/lxc/cmd/meson.build:64:4: ERROR: Unknown variable "libcap_static".

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-07-14 17:13:18 +02:00
Christian Brauner
4ef148de7a
Merge pull request #4166 from ffontaine/master
src/lxc/log.h: fix STRERROR_R_CHAR_P
2022-07-14 15:40:54 +01:00
Fabrice Fontaine
8ee8879083 src/lxc/log.h: fix STRERROR_R_CHAR_P
STRERROR_R_CHAR_P is always defined to 0 or 1 depending on the value of
have_func_strerror_r_char_p in meson.build so replace #ifdef by #if to
avoid a redefinition build failure if char *strerror_r is not defined

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-07-14 12:33:17 +02:00
Christian Brauner
b96e9ae47a
Merge pull request #4163 from Blub/meson/remaining-checks.2022-07-04
meson: add remaining still-in-use config checks
2022-07-04 13:22:37 +02:00
Wolfgang Bumiller
353f0f9926 meson: add remaining still-in-use config checks
These are all still in use in the code but have not been
added to meson.build when switching over from autoconf.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-04 12:01:10 +02:00
Christian Brauner
de6d054d22
Merge pull request #4151 from Teemperor/FixUninitRead
Fix uninitialized read in parse_cap when libcap is not used
2022-07-04 10:10:17 +02:00
Christian Brauner
890d0da215
Merge pull request #4161 from srd424/patch-1
Fix errors constructing mount string when extra mount options supplied
2022-07-04 09:23:02 +02:00
srd424
3d360cf9db
Store mount options in correct variable
This was exposed by the fix in the previous commit.

Signed-off-by: srd424 <srd424@users.noreply.github.com>
2022-07-03 18:18:23 +01:00
srd424
df3301046f
Fix off-by-one error constructing mount options
This fixes a really subtle off-by-one error constructing overlay mount options if rootfs options are provided and modern overlayfs (i.e. requiring a workdir) is used. We need to allow for the extra "," required to separate the extra options when computing the length!

Signed-off-by: srd424 <srd424@users.noreply.github.com>
2022-07-03 10:21:30 +01:00
Christian Brauner
cf1f3bc459
Merge pull request #4159 from Blub/meson/statvfs
add check for statvfs
2022-07-01 14:57:41 +02:00
Wolfgang Bumiller
a5e32dabc6
Merge pull request #4158 from brauner/2022-07-01.fixes
start: fix namespace sharing
2022-07-01 13:40:24 +02:00
Wolfgang Bumiller
8ee615c27d add check for statvfs
we use HAVE_STATVFS in the code but with meson the check got
lost causing mount_entry to fail to remount some things such
as a bind mount of /dev/fuse via

    lxc.mount.entry = /dev/fuse dev/fuse none bind,create=file 0 0

which would cause the following log messages:

    DEBUG    conf - ../src/lxc/conf.c:mount_entry:2416 - Remounting "/dev/fuse" on "/usr/lib/x86_64-linux-gnu/lxc/rootfs/dev/fuse" to respect bind or remount options
    ERROR    conf - ../src/lxc/conf.c:mount_entry:2459 - Operation not permitted - Failed to mount "/dev/fuse" on "/usr/lib/x86_64-linux-gnu/lxc/rootfs/dev/fuse"

note that the `Flags for ... were ...` line is not showing
up there, which depends on HAVE_STATVFS

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-01 11:18:50 +02:00
Christian Brauner
85a273b596
Merge pull request #4147 from marcfiu/issue-4026
fix for issue #4026: set broadcast to 0.0.0.0 for /31 and /32
2022-07-01 10:16:17 +02:00
Christian Brauner
07a00b78f0
start: fix namespace sharing
Fixes: #4134
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-07-01 10:15:17 +02:00
Stéphane Graber
59d483ef49
Merge pull request #4157 from brauner/2022-06-30.fixes
conf: fix append_ttyname()
2022-06-30 11:20:26 -04:00
Christian Brauner
eae44ce199
conf: fix append_ttyname()
We appended container_tty= and then used setenv(container_tty, ...)
resulting int container_tty=container_tty=.

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-30 12:48:01 +02:00
Stéphane Graber
10ae11cc79
Merge pull request #4154 from brauner/2022-06-29.fixes
conf: startup fixes
2022-06-29 13:09:48 -04:00
Christian Brauner
6c50e09f2c
start: record inherited namespaces earlier to make it available for idmapped rootfs setup
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-29 18:31:37 +02:00
Christian Brauner
7317d2a8a7
start: don't overwrite file descriptors during namespace preservation
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-29 18:31:01 +02:00
Christian Brauner
fc133a9f37
conf: log file descriptors on error during idmapped mount setup
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
2022-06-29 18:29:52 +02:00
Marc E. Fiuczynski
26de6cbc8d 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-06-27 15:15:48 -04:00
Christian Brauner
2e6e374c0a
Merge pull request #4153 from brauner/2022-06-21.unprivileged-cgroup2
use systemd dbus StartTransientUnit for unpriv cgroup2
2022-06-21 16:27:49 +02:00
Serge Hallyn
c55353f84a
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-06-21 16:01:13 +02:00
Raphael Isemann
b203e1a141 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-06-21 13:19:21 +02:00
Christian Brauner
0a73102d43
Merge pull request #4149 from petris/lxc_multicall
tools: Provide multicall lxc binary
2022-06-18 15:33:00 +02:00
Stéphane Graber
e73520adf4
meson: Set DEVEL flag post release
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2022-06-16 16:41:05 -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
Petr Malat
f4d02217ee tools: Provide multicall lxc binary
Create a binary, which embeds all lxc tools similar way as busybox
embeds its applets. This is handy for embedded systems as it saves
roughly 90% of the disk space.

To disable normal tools and use multicall binary exclusively use the
following meson setup options:
  -Dtools=false -Dtools-multicall=true

Signed-off-by: Petr Malat <oss@malat.biz>
2022-06-15 16:27:47 +02:00
Petr Malat
289d6413eb 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-06-15 16:06:10 +02: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