mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
Merge pull request #29558 from mrc0mmand/varlinkctl-tests
varlink: add a couple of tests + accompanying fixes
This commit is contained in:
commit
36d87065f2
|
@ -147,8 +147,27 @@ corpus should be built and exported as `$OUT/fuzz-foo_seed_corpus.zip` in
|
|||
`tools/oss-fuzz.sh`.
|
||||
|
||||
The fuzzers can be built locally if you have libFuzzer installed by running
|
||||
`tools/oss-fuzz.sh`. You should also confirm that the fuzzers can be built and
|
||||
run using
|
||||
`tools/oss-fuzz.sh`, or by running:
|
||||
|
||||
```
|
||||
CC=clang CXX=clang++ \
|
||||
meson setup build-libfuzz -Dllvm-fuzz=true -Db_sanitize=address,undefined -Db_lundef=false \
|
||||
-Dc_args='-fno-omit-frame-pointer -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION'
|
||||
ninja -C build-libfuzz fuzzers
|
||||
```
|
||||
|
||||
Each fuzzer then can be then run manually together with a directory containing
|
||||
the initial corpus:
|
||||
|
||||
```
|
||||
export UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1
|
||||
build-libfuzz/fuzz-varlink-idl test/fuzz/fuzz-varlink-idl/
|
||||
```
|
||||
|
||||
Note: the `halt_on_error=1` UBSan option is especially important, otherwise
|
||||
the fuzzer won't crash when undefined behavior is triggered.
|
||||
|
||||
You should also confirm that the fuzzers can be built and run using
|
||||
[the OSS-Fuzz toolchain](https://google.github.io/oss-fuzz/advanced-topics/reproducing/#building-using-docker):
|
||||
|
||||
```
|
||||
|
|
33
src/fuzz/fuzz-varlink-idl.c
Normal file
33
src/fuzz/fuzz-varlink-idl.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fuzz.h"
|
||||
#include "io-util.h"
|
||||
#include "varlink-idl.h"
|
||||
#include "log.h"
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
_cleanup_(varlink_interface_freep) VarlinkInterface *vi = NULL;
|
||||
_cleanup_free_ char *str = NULL, *dump = NULL;
|
||||
int r;
|
||||
|
||||
log_set_max_level(LOG_CRIT);
|
||||
log_parse_environment();
|
||||
(void) log_open();
|
||||
|
||||
assert_se(str = memdup_suffix0(data, size));
|
||||
|
||||
r = varlink_idl_parse(str, /* line= */ NULL, /* column= */ NULL, &vi);
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed to parse varlink interface definition: %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert_se(varlink_idl_format(vi, &dump) >= 0);
|
||||
(void) varlink_idl_consistent(vi, LOG_DEBUG);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -12,4 +12,5 @@ simple_fuzzers += files(
|
|||
'fuzz-time-util.c',
|
||||
'fuzz-udev-database.c',
|
||||
'fuzz-varlink.c',
|
||||
'fuzz-varlink-idl.c',
|
||||
)
|
||||
|
|
|
@ -729,11 +729,7 @@ static int varlink_idl_subparse_struct_or_enum(
|
|||
|
||||
if (!token)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
|
||||
if (streq(token, "#")) {
|
||||
r = varlink_idl_subparse_comment(p, line, column);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else if (streq(token, ")"))
|
||||
if (streq(token, ")"))
|
||||
state = STATE_DONE;
|
||||
else {
|
||||
field_name = TAKE_PTR(token);
|
||||
|
@ -986,6 +982,9 @@ int varlink_idl_parse(
|
|||
assert(!symbol);
|
||||
n_fields = 0;
|
||||
|
||||
if (!token)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
|
||||
|
||||
r = varlink_symbol_realloc(&symbol, n_fields);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -1004,6 +1003,9 @@ int varlink_idl_parse(
|
|||
case STATE_METHOD_ARROW:
|
||||
assert(symbol);
|
||||
|
||||
if (!token)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
|
||||
|
||||
if (!streq(token, "->"))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Unexpected token '%s'.", *line, *column, token);
|
||||
|
||||
|
@ -1025,6 +1027,9 @@ int varlink_idl_parse(
|
|||
assert(!symbol);
|
||||
n_fields = 0;
|
||||
|
||||
if (!token)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
|
||||
|
||||
r = varlink_symbol_realloc(&symbol, n_fields);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -1050,6 +1055,9 @@ int varlink_idl_parse(
|
|||
assert(!symbol);
|
||||
n_fields = 0;
|
||||
|
||||
if (!token)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Premature EOF.", *line, *column);
|
||||
|
||||
r = varlink_symbol_realloc(&symbol, n_fields);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -1178,13 +1186,13 @@ bool varlink_idl_interface_name_is_valid(const char *name) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static int varlink_idl_symbol_consistent(const VarlinkInterface *interface, const VarlinkSymbol *symbol, bool level);
|
||||
static int varlink_idl_symbol_consistent(const VarlinkInterface *interface, const VarlinkSymbol *symbol, int level);
|
||||
|
||||
static int varlink_idl_field_consistent(
|
||||
const VarlinkInterface *interface,
|
||||
const VarlinkSymbol *symbol,
|
||||
const VarlinkField *field,
|
||||
bool level) {
|
||||
int level) {
|
||||
|
||||
const char *symbol_name;
|
||||
int r;
|
||||
|
@ -1276,7 +1284,7 @@ static bool varlink_symbol_is_empty(const VarlinkSymbol *symbol) {
|
|||
static int varlink_idl_symbol_consistent(
|
||||
const VarlinkInterface *interface,
|
||||
const VarlinkSymbol *symbol,
|
||||
bool level) {
|
||||
int level) {
|
||||
|
||||
_cleanup_(set_freep) Set *input_set = NULL, *output_set = NULL;
|
||||
const char *symbol_name;
|
||||
|
@ -1313,7 +1321,7 @@ static int varlink_idl_symbol_consistent(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int varlink_idl_consistent(const VarlinkInterface *interface, bool level) {
|
||||
int varlink_idl_consistent(const VarlinkInterface *interface, int level) {
|
||||
_cleanup_(set_freep) Set *name_set = NULL;
|
||||
int r;
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ bool varlink_idl_field_name_is_valid(const char *name);
|
|||
bool varlink_idl_symbol_name_is_valid(const char *name);
|
||||
bool varlink_idl_interface_name_is_valid(const char *name);
|
||||
|
||||
int varlink_idl_consistent(const VarlinkInterface *interface, bool level);
|
||||
int varlink_idl_consistent(const VarlinkInterface *interface, int level);
|
||||
|
||||
const VarlinkSymbol* varlink_idl_find_symbol(const VarlinkInterface *interface, VarlinkSymbolType type, const char *name);
|
||||
const VarlinkField* varlink_idl_find_field(const VarlinkSymbol *symbol, const char *name);
|
||||
|
|
|
@ -193,11 +193,13 @@ Now install necessary build & test dependencies:
|
|||
## PPA with some newer Ubuntu packages required by upstream systemd
|
||||
# add-apt-repository -y --enable-source ppa:upstream-systemd-ci/systemd-ci
|
||||
# apt build-dep -y systemd
|
||||
# apt install -y autopkgtest debhelper genisoimage git qemu-system-x86
|
||||
# apt install -y autopkgtest debhelper genisoimage git qemu-system-x86 \
|
||||
libcurl4-openssl-dev libfdisk-dev libtss2-dev libfido2-dev \
|
||||
libssl-dev python3-pefile
|
||||
|
||||
Build systemd deb packages with debug info:
|
||||
|
||||
# TEST_UPSTREAM=1 DEB_BUILD_OPTIONS="nocheck nostrip" dpkg-buildpackage -us -uc
|
||||
# TEST_UPSTREAM=1 DEB_BUILD_OPTIONS="nocheck nostrip noopt" dpkg-buildpackage -us -uc
|
||||
# cd ..
|
||||
|
||||
Prepare a testbed image for autopkgtest (tweak the release as necessary):
|
||||
|
@ -210,7 +212,7 @@ And finally run the autopkgtest itself:
|
|||
--timeout-factor=3 \
|
||||
--test-name=boot-and-services \
|
||||
--shell-fail \
|
||||
-- autopkgtest-virt-qemu --ram-size 2048 autopkgtest-jammy-amd64.img
|
||||
-- autopkgtest-virt-qemu --cpus 4 --ram-size 2048 autopkgtest-jammy-amd64.img
|
||||
|
||||
where --test-name= is the name of the test you want to run/debug. The
|
||||
--shell-fail option will pause the execution in case the test fails and shows
|
||||
|
|
BIN
test/fuzz/fuzz-varlink-idl/crash-d1860f2b
Normal file
BIN
test/fuzz/fuzz-varlink-idl/crash-d1860f2b
Normal file
Binary file not shown.
100
test/fuzz/fuzz-varlink-idl/interface1
Normal file
100
test/fuzz/fuzz-varlink-idl/interface1
Normal file
|
@ -0,0 +1,100 @@
|
|||
# https://varlink.org/Interface-Definition
|
||||
interface org.foo.bar
|
||||
|
||||
type MyOtherType(
|
||||
x: T
|
||||
)
|
||||
|
||||
type T ( x: TT )
|
||||
type TT ( x: TTT )
|
||||
type TTT ( x: TTTT )
|
||||
type TTTT ( x: TTTTT )
|
||||
type TTTTT ( x: TTTTTT )
|
||||
type TTTTTT ( x: TTTTTTT )
|
||||
type TTTTTTT ( x: TTTTTTTT )
|
||||
type TTTTTTTT ( x: TTTTTTTTT )
|
||||
type TTTTTTTTT ( x: TTTTTTTTTT )
|
||||
type TTTTTTTTTT ( x: TTTTTTTTTTT )
|
||||
type TTTTTTTTTTT ( x: TTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTT ( x: TTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTT ( x: TTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TT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TTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT )
|
||||
type TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ( x: bool )
|
||||
|
||||
type MyType (
|
||||
example_bool: bool,
|
||||
example_int: int,
|
||||
example_float: float,
|
||||
example_string: string,
|
||||
example_object: object,
|
||||
example_enum_single: (one),
|
||||
example_enum: (one, two, three),
|
||||
example_struct_single: (first: int),
|
||||
example_struct: (first: int, second: string),
|
||||
example_array: []string,
|
||||
example_dictionary: [string]string,
|
||||
example_stringset: [string](a, b, c),
|
||||
example_stringset2: [string](a: int, b: bool, c: object),
|
||||
example_nullable: ?string,
|
||||
example_nullable_array_struct: ?[](first: int, second: string),
|
||||
example_other_type: MyOtherType
|
||||
)
|
||||
|
||||
method Foo(a: int, b: MyType) -> (bar: []string, baz: float, more: (i: int, f: float, s: string))
|
||||
method VoidArgs() -> (a: int)
|
||||
method VoidRet(a: int) -> ()
|
||||
method Void() -> ()
|
||||
|
||||
error UnknownAction(action: string, more_data: ?string)
|
||||
error VoidError()
|
89
test/units/testsuite-74.varlinkctl.sh
Executable file
89
test/units/testsuite-74.varlinkctl.sh
Executable file
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
# Unset $PAGER so we don't have to use --no-pager everywhere
|
||||
export PAGER=
|
||||
|
||||
varlinkctl --help
|
||||
varlinkctl help --no-pager
|
||||
varlinkctl --version
|
||||
varlinkctl --json=help
|
||||
|
||||
# TODO: abstract namespace sockets (@...)
|
||||
# Path to a socket
|
||||
varlinkctl info /run/systemd/journal/io.systemd.journal
|
||||
varlinkctl info /run/systemd/../systemd/../../run/systemd/journal/io.systemd.journal
|
||||
varlinkctl info "./$(realpath --relative-to="$PWD" /run/systemd/journal/io.systemd.journal)"
|
||||
varlinkctl info unix:/run/systemd/journal/io.systemd.journal
|
||||
varlinkctl info --json=off /run/systemd/journal/io.systemd.journal
|
||||
varlinkctl info --json=pretty /run/systemd/journal/io.systemd.journal | jq .
|
||||
varlinkctl info --json=short /run/systemd/journal/io.systemd.journal | jq .
|
||||
varlinkctl info -j /run/systemd/journal/io.systemd.journal | jq .
|
||||
|
||||
varlinkctl list-interfaces /run/systemd/journal/io.systemd.journal
|
||||
varlinkctl list-interfaces -j /run/systemd/journal/io.systemd.journal | jq .
|
||||
|
||||
varlinkctl introspect /run/systemd/journal/io.systemd.journal io.systemd.Journal
|
||||
varlinkctl introspect -j /run/systemd/journal/io.systemd.journal io.systemd.Journal | jq .
|
||||
|
||||
if command -v userdbctl >/dev/null; then
|
||||
systemctl start systemd-userdbd
|
||||
varlinkctl call /run/systemd/userdb/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord '{ "userName" : "testuser", "service" : "io.systemd.Multiplexer" }'
|
||||
varlinkctl call -j /run/systemd/userdb/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord '{ "userName" : "testuser", "service" : "io.systemd.Multiplexer" }' | jq .
|
||||
varlinkctl call --more /run/systemd/userdb/io.systemd.Multiplexer io.systemd.UserDatabase.GetMemberships '{ "service" : "io.systemd.Multiplexer" }'
|
||||
varlinkctl call --more -j /run/systemd/userdb/io.systemd.Multiplexer io.systemd.UserDatabase.GetMemberships '{ "service" : "io.systemd.Multiplexer" }' | jq --seq .
|
||||
varlinkctl call --oneway /run/systemd/userdb/io.systemd.Multiplexer io.systemd.UserDatabase.GetMemberships '{ "service" : "io.systemd.Multiplexer" }'
|
||||
(! varlinkctl call --oneway /run/systemd/userdb/io.systemd.Multiplexer io.systemd.UserDatabase.GetMemberships '{ "service" : "io.systemd.Multiplexer" }' | grep .)
|
||||
fi
|
||||
|
||||
IDL_FILE="$(mktemp)"
|
||||
varlinkctl introspect /run/systemd/journal/io.systemd.journal io.systemd.Journal | tee "${IDL_FILE:?}"
|
||||
varlinkctl validate-idl "$IDL_FILE"
|
||||
varlinkctl validate-idl "$IDL_FILE"
|
||||
cat /bin/sh >"$IDL_FILE"
|
||||
(! varlinkctl validate-idl "$IDL_FILE")
|
||||
|
||||
if [[ -x /usr/lib/systemd/systemd-pcrextend ]]; then
|
||||
# Path to an executable
|
||||
varlinkctl info /usr/lib/systemd/systemd-pcrextend
|
||||
varlinkctl info exec:/usr/lib/systemd/systemd-pcrextend
|
||||
varlinkctl list-interfaces /usr/lib/systemd/systemd-pcrextend
|
||||
varlinkctl introspect /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend
|
||||
fi
|
||||
|
||||
# Go through all varlink sockets we can find under /run/systemd/ for some extra coverage
|
||||
find /run/systemd/ -name "io.systemd*" -type s | while read -r socket; do
|
||||
varlinkctl info "$socket"
|
||||
|
||||
varlinkctl list-interfaces "$socket" | while read -r interface; do
|
||||
varlinkctl introspect "$socket" "$interface"
|
||||
done
|
||||
done
|
||||
|
||||
(! varlinkctl)
|
||||
(! varlinkctl "")
|
||||
(! varlinkctl info)
|
||||
(! varlinkctl info "")
|
||||
(! varlinkctl info /run/systemd/notify)
|
||||
(! varlinkctl info /run/systemd/private)
|
||||
# Relative paths must begin with ./
|
||||
(! varlinkctl info "$(realpath --relative-to="$PWD" /run/systemd/journal/io.systemd.journal)")
|
||||
(! varlinkctl info unix:)
|
||||
(! varlinkctl info unix:"")
|
||||
(! varlinkctl info exec:)
|
||||
(! varlinkctl info exec:"")
|
||||
(! varlinkctl list-interfaces)
|
||||
(! varlinkctl list-interfaces "")
|
||||
(! varlinkctl introspect)
|
||||
(! varlinkctl introspect /run/systemd/journal/io.systemd.journal)
|
||||
(! varlinkctl introspect /run/systemd/journal/io.systemd.journal "")
|
||||
(! varlinkctl introspect "" "")
|
||||
(! varlinkctl call)
|
||||
(! varlinkctl call "")
|
||||
(! varlinkctl call "" "")
|
||||
(! varlinkctl call "" "" "")
|
||||
(! varlinkctl call /run/systemd/userdb/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord </dev/null)
|
||||
(! varlinkctl validate-idl "")
|
||||
(! varlinkctl validate-idl </dev/null)
|
Loading…
Reference in a new issue