Commit Graph

11579 Commits

Author SHA1 Message Date
Stéphane Graber
fbc31691ee
github: Update for main branch
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-07-24 11:38:07 -04:00
Christian Brauner
5a82a3f90e
Merge pull request #4327 from hallyn/2023-07-17/ai
CONTRIBUTING: add a note on AI generated code
2023-07-17 19:04:37 +02:00
Serge Hallyn
69e51b919e CONTRIBUTING: add a note on AI generated code
Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2023-07-17 07:57:17 -05:00
Christian Brauner
43a0751ecd
Merge pull request #4324 from hallyn/2023-07-06/bequiet
get_hierarchy: dont WARN about no usable controller
2023-07-07 12:48:59 +02:00
Serge Hallyn
84cfe97724 get_hierarchy: dont WARN about no usable controller
If I start a container with loglevel WARN, and (on a pretty
stock ubuntu) do lxc-info -n $c, I get

lxc-start media 20230706233337.765 WARN     cgfsng - cgroups/cgfsng.c:get_hierarchy:142 - There is no useable cpuacct controller
lxc-start media 20230706233337.765 WARN     cgfsng - cgroups/cgfsng.c:get_hierarchy:142 - There is no useable blkio controller

I don't think that's worth WARNing about, so change it to
INFO.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2023-07-06 18:34:59 -05:00
Stéphane Graber
213e2f68d9
github: Add DCO/target tests
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2023-06-21 21:45:27 -04:00
Christian Brauner
8aab05bd9d
Merge pull request #4313 from mosbrew-ag/master
explicitly convert *mainloop_handler to __u64
2023-05-26 08:34:49 +02:00
Anatolii Gryzlov
cf2b202093 explicitly convert *mainloop_handler to __u64
GCC treats such conversion as warning, while Clang-15 aborts compilation

Signed-off-by: Anatolii Gryzlov <agryzlov.mosbrew@gmail.com>
2023-05-25 02:39:49 +03:00
Stéphane Graber
883311259d
Merge pull request #4310 from magalilemes/parse-config-file
tests: fix parse_config_file seccomp test
2023-05-16 13:37:40 -04:00
Magali Lemes
8575ffeb7f tests: fix parse_config_file seccomp test
Link: https://bugs.launchpad.net/ubuntu-kernel-tests/+bug/1980218
Check if seccomp is enabled before throwing error.

Signed-off-by: Magali Lemes <magali.lemes@canonical.com>
2023-05-15 20:31:37 -03:00
Christian Brauner
70e42b0f93
Merge pull request #4309 from stgraber/master
src/tests: Fix container creation errors
2023-05-05 09:33:22 +02:00
Stéphane Graber
ca25f3bf64
src/tests: Fix container creation errors
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2023-05-04 16:58:56 +02:00
Christian Brauner
0e69800b70
Merge pull request #4305 from hallyn/2023-04-21/private_symbols
rename functions which clash with libsystemd's
2023-04-22 08:34:03 +02:00
Serge Hallyn
539c397725 rename functions which clash with libsystemd's
If statically linking against both liblxc and libsystemd, some
function names conflict:

mkdir_p fd_cloexec path_simplify is_dir is_fs_type

Rename those to lxc_\0, as:

for sym in mkdir_p fd_cloexec path_simplify is_dir is_fs_type; do
	git grep "$sym" | awk -F: '{ print $1 }' | sort | uniq | xargs sed -i "s/$sym/lxc_$sym/g"
done

(the above loop wrongly replaces is_dir in meson.build, but
c'est la vie)

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2023-04-21 19:12:21 -05:00
Stéphane Graber
a7dcde0386
Merge pull request #4304 from mihalicyn/io_uring_stuck_fix
mainloop: fix stuck when io_uring is enabled
2023-04-21 14:12:44 -04:00
Alexander Mikhalitsyn
7fd671dbce
mainloop: io_uring: disable IORING_POLL_ADD_MULTI
Let's disable IORING_POLL_ADD_MULTI to workaround an issue
with false-positive POLLIN events in CQ.

In my local setup I managed to fix an issue without this
by making terminal FDs non-blocking, but during full
testsuite execution in Jenkins it was found that issue
still persists. So, let's add this ugly workaround too.

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-04-21 19:23:06 +02:00
Alexander Mikhalitsyn
715fb4effa
terminal: make a terminal FDs non-blocking
Let's prevent freezes on read(2) by making a terminal FDs non-blocking.

It was discovered that there is an issue with io_uring mainloop when
multishot poll (IORING_POLL_ADD_MULTI) mode is enabled. Sometimes
false-positive poll events are put into a CQ. It makes further read(2)
stuck forever and blocks all mainloop processing for an infinite time.

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-04-21 18:53:49 +02:00
Alexander Mikhalitsyn
7eff16cc4c
file_utils: add fd_make_nonblocking helper
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-04-21 18:53:33 +02:00
Alexander Mikhalitsyn
747c4df31a
file_utils: rename fd_make_nonblocking to fd_make_blocking
Currently, fd_make_nonblocking does exactly the opposite thing,
it clears O_NONBLOCK flag and makes fd blocking.

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-04-21 18:52:58 +02:00
Christian Brauner
0d1ffe0769
Merge pull request #4300 from solardiz/setproctitle
setproctitle(): Handle potential NULL return from strrchr()
2023-04-11 17:25:35 +02:00
Solar Designer
ebea2b5a99 setproctitle(): Handle potential NULL return from strrchr()
Signed-off-by: Solar Designer <solar@openwall.com>
2023-04-11 16:14:37 +02:00
Christian Brauner
e2d10d666c
Merge pull request #4299 from tych0/make-setproctitle-safe
make setproctitle()'s /proc/pid/stat parsing safe
2023-04-11 07:47:32 +02:00
Tycho Andersen
f7f15b20a3 make setproctitle()'s /proc/pid/stat parsing safe
it turns out that our parsing of /proc/pid/stat was not safe in general
(though probably safe for lxc, since our executable names do not contain
spaces).

Let's fix this by looking backwards through the file for ), and then
continuing on from there.

This was reported to me by Solar Designer, who pointed me to this thread:
https://twitter.com/solardiz/status/1634204168545001473

Indeed, this is a lot of tap dancing to work around the kernel's 16
character executable limit. Perhaps I'll send a kernel patch to raise that
limit next.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
2023-04-10 17:20:47 -06:00
Serge Hallyn
52326514c6
Merge pull request #4287 from hallyn/2023-03-10/dbus
switch from libsystemd's dbus to dbus-1
2023-03-19 17:05:06 -05:00
Serge Hallyn
5894cf3101 console-log test: make sure container is stopped before restarting
Closes #4237

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2023-03-19 16:04:46 -05:00
Serge Hallyn
820d2a2b3a switch from libsystemd's dbus to dbus-1
This is purely so that we can do static linking.  Linking against
libsystemd makes that a challenge because while it's perfectly simple
to do, distros tend not to provide a libsystemd.a.

Tools that want to (a) link against liblxc and (b) have a statically
linked binary to bind into a minimal container are ill served by
this.  So link against libdbus-1.

.github/workflows/build.yml: switch to dbus-1.
src/lxc/cgroups/cgfsng.c: replace the unpriv_systemd_create_scope(),
   start_scope, and enter_scope() systemd code with dbus-1 code.
src/tests/oss-fuzz.sh: update from libsystemd-dev to libdbus-1-dev
src/tests/oss-fuzz.sh: disable dbus
.github/workflows/*: update from libsystemd-dev to libdbus-1-dev
meson.build and meson_options.txt: switch from sd_bus to dbus
lxc.spec.in: add dbus-1 to BuildRequires

Signed-off-by: Serge Hallyn <serge@hallyn.com>

Changelog: 03/13: use custom iter type so we can cleanup more easily...
Changelog: 03/13: initialize each dbus_iter to { 0 } as mihalicyn suggested.
2023-03-19 15:30:56 -05:00
Stéphane Graber
12887ebcc6
Merge pull request #4290 from mihalicyn/sk_cloexec
tree-wide: convert fcntl(FD_CLOEXEC) to SOCK_CLOEXEC
2023-03-17 11:20:54 -04:00
Alexander Mikhalitsyn
3c1453a38d
tree-wide: convert fcntl(FD_CLOEXEC) to SOCK_CLOEXEC
- replace accept() + fcntl(FD_CLOEXEC) with accept4(..., SOCK_CLOEXEC)
- remove fcntl(FD_CLOEXEC) in lxc_server_init() as we already set
SOCK_CLOEXEC in lxc_abstract_unix_open().

See also: ad9429e52 ("tree-wide: make socket SOCK_CLOEXEC")
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-03-17 13:43:34 +01:00
Serge Hallyn
838221c111
Merge pull request #4281 from smoser/feature/oci-squashfs
Add support for squashfs images in oci via atomfs
2023-02-27 13:57:45 -06:00
Scott Moser
4ea0b361f1 Allow fuse mounts in apparmor start-container.
Unprivledged user should be able to do fuse mounts during start-container.
Specifically this solves the problem for un-priv fuse mounting via
pre-hook.

Signed-off-by: Scott Moser <smoser@brickies.net>
2023-02-27 09:07:38 -05:00
Scott Moser
1a2da75b6e Add support for squashfs images in oci via atomfs
This adds support to the oci template for squashfs images.
It uses 'atomfs' from [1] to accomplish this.

Squashfs images (media type
application/vnd.stacker.image.layer.squashfs+zstd+verity) have several
benefits compared to tar+gz:

 * immediately mountable
 * read-only filesystem
 * verity data present in oci manifest.

I presented this at Fosdem 2023 at [2].

The 'atomfs' program can be replaced by passing '--mount-helper'
argument to the oci template.

    mount-helper mount oci:<oci_dir>:<oci_name> <mountpoint>
    mount-helper umount <mountpoint>

[1] https://github.com/project-machine/atomfs
[2] https://fosdem.org/2023/schedule/event/container_secure_storage/

Signed-off-by: Scott Moser <smoser@brickies.net>
2023-02-27 09:06:37 -05:00
Christian Brauner
71f7e788d9
Merge pull request #4284 from Blub/2023-02-27/empty-apparmor-files
apparmor: don't try to mmap empty files
2023-02-27 13:23:13 +01:00
Wolfgang Bumiller
db3cbfa75c apparmor: don't try to mmap empty files
In case empty profile files linger somehow (eg. powerloss or
oom killer etc. between creating and writing the file) we
tried to use mmap() with a length of 0 which is invalid.
Let's treat this as if it did not exist.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-27 11:08:46 +01:00
Stéphane Graber
0b286bde88
Merge pull request #4279 from mihalicyn/setproctitle_fix_fmt_spec
initutils: use PRIu64 for uint64_t in setproctitle
2023-02-16 11:15:00 -05:00
Alexander Mikhalitsyn
304bf58fa1
initutils: use PRIu64 for uint64_t in setproctitle
Kernel UAPI provides as with the following declaration:
/*
 * This structure provides new memory descriptor
 * map which mostly modifies /proc/pid/stat[m]
 * output for a task. This mostly done in a
 * sake of checkpoint/restore functionality.
 */
struct prctl_mm_map {
	__u64	start_code;		/* code section bounds */
	__u64	end_code;
	__u64	start_data;		/* data section bounds */
	__u64	end_data;
	__u64	start_brk;		/* heap for brk() syscall */
	__u64	brk;
	__u64	start_stack;		/* stack starts at */
	__u64	arg_start;		/* command line arguments bounds */
	__u64	arg_end;
	__u64	env_start;		/* environment variables bounds */
	__u64	env_end;
	__u64	*auxv;			/* auxiliary vector */
	__u32	auxv_size;		/* vector size */
	__u32	exe_fd;			/* /proc/$pid/exe link file */
};

Let's use appropriate types/format specifiers everywhere.

Issue #4268

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-02-16 13:38:28 +01:00
Stéphane Graber
2d3dab782d
Merge pull request #4277 from n0p90/fix-nft-ip6-nat
lxc-net.in: fix nftables syntax for IPv6 NAT
2023-02-13 16:36:09 -05:00
Quentin Lyons
4de047f513 lxc-net.in: fix nftables syntax for IPv6 NAT
The nftables masquarade rule for IPv6 was using the IPv4 syntax. This
resulted in the following error when starting the lxc-net.service with
LXC_IPV6_NAT="true" and nftables:

    Feb 11 18:54:54 pc lxc-net[4936]: Error: conflicting protocols specified: ip6 vs. ip
    Feb 11 18:54:54 pc lxc-net[4936]:                              ^^^^^^^^
    Feb 11 18:54:54 pc lxc-net[4917]: Failed to setup lxc-net.
    Feb 11 18:54:54 pc systemd[1]: lxc-net.service: Main process exited, code=exited, status=1/FAILURE
    Feb 11 18:54:54 pc systemd[1]: lxc-net.service: Failed with result 'exit-code'.
    Feb 11 18:54:54 pc systemd[1]: Failed to start LXC network bridge setup.

Signed-off-by: Quentin Lyons <36303164+n0p90@users.noreply.github.com>
2023-02-12 02:24:22 +00:00
Christian Brauner
08f0e76965
Merge pull request #4275 from ariel-miculas/fix_strl_rc_checks
Fix strlcat's return value checks
2023-02-07 14:16:27 +01:00
Ariel Miculas
311bb8c53e Fix strlcat's return value checks
Alternatively we could have used safe_strlcat, but it's not used
anywhere and there's also no safe_strlcpy

Signed-off-by: Ariel Miculas <amiculas@cisco.com>
2023-02-07 13:52:31 +02:00
Christian Brauner
042d8165a1
Merge pull request #4270 from ariel-miculas/fix_typo
Fix typo: bev_type -> bdev_type
2023-01-30 17:45:12 +01:00
Ariel Miculas
588b53b198 Fix typo: bev_type -> bdev_type
Signed-off-by: Ariel Miculas <amiculas@cisco.com>
2023-01-30 18:25:55 +02:00
Christian Brauner
4a1ec6086c
Merge pull request #4263 from hallyn/2023-01-18/drop-fuzz-test
drop broken lxc-test-fuzzers
2023-01-23 23:59:12 +01:00
Serge Hallyn
7914c259f2 drop broken lxc-test-fuzzers
Closes #4261

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2023-01-20 15:19:03 -06:00
Stéphane Graber
a1874c80dc
Merge pull request #4255 from gibmat/fix-sparc64-link-error
Fix build error on sparc64 caused by using the gold linker
2023-01-10 20:08:00 -05:00
Mathias Gibbens
849d808779
Fix build error on sparc64 caused by using the gold linker
Signed-off-by: Mathias Gibbens <gibmat@debian.org>
2023-01-10 23:20:14 +00:00
Stéphane Graber
e343a16122
Merge pull request #4253 from hallyn/2023-01-09/overlay
lxc-default-cgns apparmor profile: allow overlay mounts
2023-01-09 17:30:28 -05:00
Serge Hallyn
43ad7816d8 lxc-default-cgns apparmor profile: allow overlay mounts
Signed-off-by: Serge Hallyn <serge@hallyn.com>
2023-01-09 13:36:45 -06:00
Christian Brauner
2097da81da
Merge pull request #4252 from mihalicyn/create_nic_fix
lxc_user_nic: fix get_mtu() error handling
2023-01-06 20:40:34 +01:00
Serge Hallyn
1b25a401b7
Merge pull request #4245 from MaherAzzouzi/master
Patching an incoming CVE (CVE-2022-47952)
2023-01-06 12:59:21 -06:00
Alexander Mikhalitsyn
4fa83282b5
lxc_user_nic: fix get_mtu() error handling
get_mtu() returns int, but "mtu" variable has unsigned int type.
It leads to logical error in error handling, which can end up
with strange -EINVAL error in lxc_veth_create(), cause (mtu > 0)
condition is met, but negative "mtu" value is too large when set
as mtu for network device.

Issue #4232

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-01-06 17:05:07 +01:00