Commit Graph

11006 Commits

Author SHA1 Message Date
Evgeny Vereshchagin
77d755ce04 README: add OSS-Fuzz/CIFuzz badges
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2021-03-26 05:20:51 +00:00
Evgeny Vereshchagin
f329f022a9 fuzz: create tmpfiles in /tmp
It's mostly a cosmetic change that should prevent the fuzzer
from cluttering the "$OUT" directory (which OSS-Fuzz uses to
build docker images):

```
Step #44: Already have image: gcr.io/oss-fuzz/lxc
Step #44:   adding: fuzz-lxc-config-read (deflated 67%)
Step #44:   adding: fuzz-lxc-config-read-WBWKxN (deflated 32%)
Step #44:   adding: fuzz-lxc-config-read_seed_corpus.zip (stored 0%)
Step #44:   adding: honggfuzz (deflated 66%)
Step #44:   adding: llvm-symbolizer (deflated 65%)
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2021-03-26 05:20:07 +00:00
Sam Boyles
bb301db761 network: handle name collisions when returning physical interfaces to host
Reviewed-by: Blair Steven <blair.steven@alliedtelesis.co.nz>
Signed-off-by: Sam Boyles <sam.boyles@alliedtelesis.co.nz>
2021-03-26 15:27:07 +13:00
Evgeny Vereshchagin
dec64820a3 oss-fuzz: make it possible to build the fuzzer without docker
With this patch applied the fuzz target can be built (with ASan)
and run with
```
./src/tests/oss-fuzz.sh
./out/fuzz-lxc-config-read doc/examples/
```

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32475 can be
reproduced by running
```
$ echo "lxc.console.buffer.size=d" >oss-fuzz-32475
$ ./out/fuzz-lxc-config-read ./oss-fuzz-32475
INFO: Seed: 1044753468
INFO: Loaded 1 modules   (18770 inline 8-bit counters): 18770 [0x883cc0, 0x888612),
INFO: Loaded 1 PC tables (18770 PCs): 18770 [0x888618,0x8d1b38),
./out/fuzz-lxc-config-read: Running 1 inputs 1 time(s) each.
Running: oss-fuzz-32475
=================================================================
==2052097==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffcca063e7f at pc 0x000000659e0d bp 0x7ffcca063e30 sp 0x7ffcca063e28
READ of size 1 at 0x7ffcca063e7f thread T0
...
```

I'll point OSS-Fuzz to the build script once this patch is merged.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2021-03-26 01:11:23 +00:00
Stéphane Graber
27df252817
Merge pull request #3729 from brauner/2021-03-25/fixes_3
oss-fuzz: fixes
2021-03-25 19:17:37 -04:00
Christian Brauner
b8e43ef0bd
conf: use lxc_list_new() everywhere
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-25 23:49:37 +01:00
Christian Brauner
642751ccd0
confile: use lxc_list_new() everywhere
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-25 23:38:24 +01:00
Christian Brauner
89d34eb2ed
list: add lxc_list_new() helper
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-25 23:33:12 +01:00
Christian Brauner
c461b9c7ed
confile_utils: delete netdev from list
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32478
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-25 23:22:53 +01:00
Christian Brauner
4a2c9b4023
conf: reinitialize sysctl list after clearing it
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32474
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-25 23:10:57 +01:00
Christian Brauner
b5fdc164e3
confile: fix set_config_sysctl()
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32487
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-25 23:07:22 +01:00
Christian Brauner
65c5bc571b
Merge pull request #3726 from evverx/cifuzz
ci: turn on CIFuzz
2021-03-25 16:45:02 +01:00
Christian Brauner
854e6c5c01
Merge pull request #3725 from evverx/se_keyring_context_memory_leak
conf: fix a memory leak
2021-03-25 15:51:19 +01:00
Stéphane Graber
3c9c460953
Merge pull request #3724 from brauner/2021-03-25/fixes
confile_utils: don't free netdev twice
2021-03-25 08:26:55 -04:00
Evgeny Vereshchagin
4117b26a0e ci: turn on CIFuzz
Now that lxc has been integrated into OSS-Fuzz it should be
possible to start using https://google.github.io/oss-fuzz/getting-started/continuous-integration/
(mostly to make sure that the project is buildable there).

It should help to keep the integration in more or less good shape.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2021-03-25 09:40:51 +00:00
Evgeny Vereshchagin
1ed59e6d8d conf: fix a memory leak
It was triggered by passing "lxc.selinux.context.keyring=xroot" to the
fuzz target introduced in https://github.com/google/oss-fuzz/pull/5498
```
=================================================================
==22==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6 byte(s) in 1 object(s) allocated from:
    #0 0x538ca4 in __strdup /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:468:3
    #1 0x5c40e8 in set_config_string_item /src/lxc/src/lxc/confile_utils.c:635:14
    #2 0x44394e in set_config_selinux_context_keyring /src/lxc/src/lxc/confile.c:1596:9
    #3 0x5af955 in parse_line /src/lxc/src/lxc/confile.c:2953:9
    #4 0x4475cd in lxc_file_for_each_line_mmap /src/lxc/src/lxc/parse.c:125:9
    #5 0x5af24f in lxc_config_read /src/lxc/src/lxc/confile.c:3024:9
    #6 0x580b04 in LLVMFuzzerTestOneInput /src/fuzz-lxc-config-read.c:36:2
    #7 0x483643 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
    #8 0x46d4a2 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:323:6
    #9 0x4732ea in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:856:9
    #10 0x49f022 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #11 0x7f16d09b883f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
```

This is a follow-up to https://github.com/lxc/lxc/commit/4fef78bc332a2d186dca6f

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2021-03-25 09:09:07 +00:00
Christian Brauner
5b1030e26c
confile_utils: don't free netdev twice
lxc_free_netdev() will already free the list element.

Fixes: https://github.com/google/oss-fuzz/pull/5498
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-25 08:23:25 +01:00
Stéphane Graber
38b4b216bb
Merge pull request #3720 from brauner/2021-03-23/fixes
strchrnul: fix copy-paste braino
2021-03-23 08:53:36 -04:00
Christian Brauner
10bf1adb43
strchrnul: fix copy-paste braino
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-23 11:34:57 +01:00
Stéphane Graber
678d600f50
Merge pull request #3719 from brauner/2021-03-22/fixes
strchrnul: ignore increased required alignment warning
2021-03-22 08:53:52 -04:00
Christian Brauner
09c3ee1390
strchrnul: ignore increased required alignment warning
Fixes: https://jenkins.linuxcontainers.org/view/LXC/job/lxc-build-android/7949/console
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-22 10:10:36 +01:00
Stéphane Graber
1d358fe9c0
Merge pull request #3718 from brauner/2021-03-21/fixes_2
configure: fix strchrnul conditiona compilation
2021-03-21 11:22:17 -04:00
Christian Brauner
7e4ea7bffd
configure: fix strchrnul conditiona compilation
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-21 16:04:35 +01:00
Stéphane Graber
3e7605b397
Merge pull request #3717 from brauner/2021-03-21/fixes
include: fix typo
2021-03-21 08:48:50 -04:00
Christian Brauner
5582dd63c3
include: fix typo
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-21 10:08:15 +01:00
Stéphane Graber
f62beebe22
Merge pull request #3716 from brauner/2021-03-19/fixes
string_utils: provide a version of strchrnul() in case it's not avail…
2021-03-20 14:56:27 -04:00
Christian Brauner
88cf3229fe
string_utils: provide a version of strchrnul() in case it's not available
This should only happen on Android.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-20 12:34:36 +01:00
Stéphane Graber
1718e6d601
Merge pull request #3715 from brauner/2021-03-18/fixes
rexec: don't close stderr
2021-03-18 08:43:28 -04:00
Christian Brauner
b75c1e611d
rexec: don't close stderr
Otherwise we'll fail to attach to containers later on.

Fixes: https://discuss.linuxcontainers.org/t/error-failed-to-retrieve-pid-of-executing-child-process
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-18 12:12:05 +01:00
Christian Brauner
45580870b0
Merge pull request #3712 from stgraber/master
github: Fix invalid syntax for coverity
2021-03-17 21:19:48 +01:00
Stéphane Graber
7b89a43d04
github: Fix invalid syntax for coverity
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-03-17 16:18:07 -04:00
Christian Brauner
e38b519e34
Merge pull request #3711 from stgraber/master
Switch to Github actions
2021-03-17 20:58:05 +01:00
Stéphane Graber
4bc1dabe06
Switch to Github actions
Travis-CI has been a disaster lately with us running out of credits or
their system thinking we're out of credit anyway...

So with Jenkins now covering arm64, let's move the rest of the CI to
Github Actions instead.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-03-17 15:55:58 -04:00
Stéphane Graber
4fece28fa1
Merge pull request #3710 from brauner/2021-03-17/fixes
macro: define __aligned_u64 to handle kernels without such support
2021-03-17 14:52:11 -04:00
Christian Brauner
b1abf15db2
macro: define __aligned_u64 to handle kernels without such support
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-17 19:28:26 +01:00
Stéphane Graber
0f1caf26d5
Merge pull request #3708 from brauner/2021-03-17/fixes
cgroups: ignore unused controllers
2021-03-17 08:40:27 -04:00
Christian Brauner
6159413bc9
cgroups: ignore unused controllers
Someone might have created a name=<controller> controller after the
container has started and so the container doesn't make use of this
controller.

Link: https://github.com/lxc/lxd/issues/8577
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-17 09:24:56 +01:00
Stéphane Graber
f62764977d
Merge pull request #3707 from brauner/2021-03-09/fixes
conf: automount fixes
2021-03-09 12:03:00 -05:00
Christian Brauner
96f306e625
conf: add missing newline in lxc_mount_auto_mounts()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-09 11:29:31 +01:00
Christian Brauner
0d33a38209
conf: simplify logging in lxc_mount_auto_mounts()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-09 11:29:03 +01:00
Christian Brauner
75fca1ac47
conf: cleanup automounting
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-09 11:27:01 +01:00
Christian Brauner
95258e34b5
conf: ensure that procfs and sysfs are unmounted
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-09 11:26:13 +01:00
Christian Brauner
ed41e764e8
conf: simplify dependent mount logic
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-09 10:48:32 +01:00
Christian Brauner
3dd3fc3164
conf: tweak comment about transient procfs mount
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-09 09:56:26 +01:00
Stéphane Graber
90b7adcc5e
Merge pull request #3706 from brauner/2021-03-05/fix_aarch64
start: handle CLONE_PIDFD on arm64
2021-03-05 16:46:09 -05:00
Christian Brauner
abd80bded6
start: handle CLONE_PIDFD on arm64
Reported-by: Ondrej Kubik <ondrej.kubik@canonical.com>
Cc: stable-4.0
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-05 19:58:26 +01:00
Stéphane Graber
673ce312c5
Merge pull request #3705 from brauner/fixes
attach_options: header improvements
2021-03-05 07:45:54 -05:00
Christian Brauner
6df53e842d
attach_options: add explicit defines for all enums
This makes it easier to detect support for various features at compile
time.

Enables: https://github.com/lxc/go-lxc/pull/149
Fixes: https://launchpadlibrarian.net/526273274/buildlog_snap_ubuntu_bionic_i386_lxd-4.0-edge_BUILDING.txt.gz
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-05 10:41:35 +01:00
Christian Brauner
a84c81bfee
attach_options: fix whitespace error in LXC_ATTACH_NO_NEW_PRIVS
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-05 10:14:27 +01:00
Christian Brauner
42b245e3c8
attach_options: explicitly number enums
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-03-05 10:13:04 +01:00