1
0
mirror of https://github.com/systemd/systemd synced 2025-11-21 01:34:44 +01:00

Compare commits

..

10 Commits

Author SHA1 Message Date
Daan De Meyer
675fa49f69 sd-id128: Drop _sd_const_ from sd_id128_in_setv()
Both the const and pure attributes disallow modifying input arguments
but sd_id128_in_setv() clearly modifies its ap input argument by iterating
over it with va_arg() so drop the _sd_const_ attribute from
sd_id128_in_setv().
2025-10-13 12:00:45 +02:00
Yu Watanabe
d1893390e5 test-kernel-install: support the case when custom default locale is specified
This also makes 'diff' command output to stderr, otherwise the
difference is eaten by meson by default, so hard to debug.
2025-10-13 10:31:43 +02:00
Yu Watanabe
d526ab8a9a mkosi: avoid infinite reboot on failure
If systemd-pcrphase-initrd.service and friends failed for some reasons,
the test VM will reboot infinitely and the test will timeout. Let's
propagate the failure to the host and fail the test earlier in that case.
2025-10-13 10:29:38 +02:00
Duy Nguyen Van
7ae7c014c3 Fix build fail when add option "-fstack-protector-all"
When using canary check with "-fstack-protector-all" option. It causes a configure
error in systemd-boot when meson.build executes compile simple code to test linker option
"-static-pie" because -nolibstd option prevents using libc. It need for
canary to provide some function as "__stack_chk_guard". So need to turn off
canary check when compile sanity check.
2025-10-13 10:27:28 +02:00
Zbigniew Jędrzejewski-Szmek
e867eeaf2b
mkosi: install test dependencies for EnterNamespace= test (#39268)
The test for the EnterNamespace= feature [0] has been both broken and
disabled since the migration to the mkosi framework, as it's missing the
libdw.pc file for pkg-config, so the test is skipped completely, and
it's also missing gcc to actually build the test binary.

[0] Part of TEST-87-AUX-UTILS-VM.coredump.sh
2025-10-13 10:10:36 +02:00
Daniel Brackenbury
4cbfaaa549 remove Nulea M501 usb entry from hwdb
conflict with other mice using same generic dongle identified (e.g. Protoarc EM11)
2025-10-13 09:44:17 +02:00
Frantisek Sumsal
80b4cacf1b test: temporarily skip the EnterNamespace= test w/o embedded debuginfo
The EnterNamespace= feature currently doesn't work if the debuginfo is
separated from the crashing binary. Until that's resolved, let's run the
test only if the test binary has embedded debuginfo (.debug_info
section; e.g. when systemd is built without WITH_DEBUG=1) or it contains
MiniDebugInfo (.gnu_debugdata section; default on Fedora and CentOS).

See: https://github.com/systemd/systemd/pull/39268#issuecomment-3390745718
2025-10-11 22:37:33 +02:00
Frantisek Sumsal
4d8e8d44ab mkosi: install test dependencies for EnterNamespace= test
The test for the EnterNamespace= feature [0] has been both broken and
disabled since the migration to the mkosi framework, as it's missing the
libdw.pc file for pkg-config, so the test is skipped completely, and
it's also missing gcc to actually build the test binary.

[0] Part of TEST-87-AUX-UTILS-VM.coredump.sh
2025-10-11 22:37:33 +02:00
Frantisek Sumsal
cfb604f8f7 test: exclude test-stacktrace(-not)?-symbolized from the coredump check
As they are expected coredumps from the EnterNamespace= feature test.
2025-10-11 22:37:33 +02:00
Frantisek Sumsal
937f609b41 test: build the crashing test binary outside of the test
So we don't have to pull in gcc and other stuff into it.

Also, make the test itself a bit more robust and debug-able.
2025-10-11 22:37:33 +02:00
21 changed files with 135 additions and 30 deletions

View File

@ -825,12 +825,9 @@ mouse:usb:v0e8fp00a7:name:DaKai 2.4G RX:*
# Nulea # Nulea
########################################## ##########################################
# Note: it is possible that other devices may use the same wireless dongle, # Note: The Nulea uses a generic USB dongle. Overriding its value would cause
# as such this could require revisiting if it causes issues with other mice # other mice to be erroneously registered as trackballs, so only bluetooth
# Nulea M501 Wireless Trackball (USB Receiver) # detection is added.
mouse:usb:v25a7pfa61:name:Compx 2.4G Receiver Mouse:*
ID_INPUT_TRACKBALL=1
# Nulea M501 Wireless Trackball (Bluetooth) # Nulea M501 Wireless Trackball (Bluetooth)
mouse:bluetooth:v000ep3412:name:Nulea BT5.0 Mouse:* mouse:bluetooth:v000ep3412:name:Nulea BT5.0 Mouse:*
ID_INPUT_TRACKBALL=1 ID_INPUT_TRACKBALL=1

View File

@ -22,6 +22,7 @@ Packages=
dbus-broker dbus-broker
dbus-broker-units dbus-broker-units
dhcp dhcp
elfutils
erofs-utils erofs-utils
f2fs-tools f2fs-tools
git git
@ -39,6 +40,7 @@ Packages=
openssl openssl
pacman pacman
perf perf
pkgconf
polkit polkit
procps-ng procps-ng
psmisc psmisc

View File

@ -28,6 +28,8 @@ Packages=
device-mapper-event device-mapper-event
device-mapper-multipath device-mapper-multipath
dfuzzer dfuzzer
elfutils-devel
elfutils-libs
erofs-utils erofs-utils
git-core git-core
glibc-langpack-de glibc-langpack-de
@ -49,6 +51,7 @@ Packages=
pam pam
passwd passwd
perf perf
pkgconf
policycoreutils policycoreutils
polkit polkit
procps-ng procps-ng

View File

@ -53,6 +53,8 @@ Packages=
isc-dhcp-server isc-dhcp-server
knot knot
libcap-ng-utils libcap-ng-utils
libdw-dev
libdw1
locales locales
login login
man-db man-db
@ -63,6 +65,7 @@ Packages=
openssh-server openssh-server
passwd passwd
polkitd polkitd
pkgconf
procps procps
psmisc psmisc
python3-pexpect python3-pexpect

View File

@ -58,6 +58,8 @@ Packages=
knot knot
libapparmor1 libapparmor1
libcap-progs libcap-progs
libdw-devel
libdw1
libtss2-tcti-device0 libtss2-tcti-device0
man man
multipath-tools multipath-tools
@ -68,6 +70,7 @@ Packages=
pam pam
patterns-base-minimal_base patterns-base-minimal_base
perf perf
pkgconf
procps4 procps4
psmisc psmisc
python3-pefile python3-pefile

View File

@ -0,0 +1,2 @@
[Unit]
FailureAction=exit

View File

@ -0,0 +1,2 @@
[Unit]
FailureAction=exit

View File

@ -0,0 +1,2 @@
[Unit]
FailureAction=exit

View File

@ -0,0 +1,2 @@
[Unit]
FailureAction=exit

View File

@ -0,0 +1,2 @@
[Unit]
FailureAction=exit

View File

@ -0,0 +1,2 @@
[Unit]
FailureAction=exit

View File

@ -207,7 +207,7 @@ efi_c_ld_args = [
] ]
linker_sanity_code = 'void a(void) {}; void _start(void) { a(); }' linker_sanity_code = 'void a(void) {}; void _start(void) { a(); }'
linker_sanity_args = ['-nostdlib', '-Wl,--fatal-warnings'] linker_sanity_args = ['-nostdlib', '-Wl,--fatal-warnings', '-fno-stack-protector']
# Check if libgcc is available and then use it. It is needed for gcc builds # Check if libgcc is available and then use it. It is needed for gcc builds
# and for ia32 builds with clang. # and for ia32 builds with clang.

View File

@ -291,7 +291,7 @@ rmdir "$BOOT_ROOT/hoge"
########################################### ###########################################
output="$("$kernel_install" -v --json=pretty inspect 1.1.1 "$D/sources/linux")" output="$("$kernel_install" -v --json=pretty inspect 1.1.1 "$D/sources/linux")"
diff -u <(echo "$output") - <<EOF diff -u <(echo "$output") - >&2 <<EOF
{ {
"MachineID" : "3e0484f3634a418b8e6a39e8828b03e3", "MachineID" : "3e0484f3634a418b8e6a39e8828b03e3",
"KernelImageType" : "unknown", "KernelImageType" : "unknown",
@ -309,7 +309,7 @@ diff -u <(echo "$output") - <<EOF
"$D/00-skip.install" "$D/00-skip.install"
], ],
"PluginEnvironment" : [ "PluginEnvironment" : [
"LC_COLLATE=C.UTF-8", "LC_COLLATE=$SYSTEMD_DEFAULT_LOCALE",
"KERNEL_INSTALL_VERBOSE=1", "KERNEL_INSTALL_VERBOSE=1",
"KERNEL_INSTALL_IMAGE_TYPE=unknown", "KERNEL_INSTALL_IMAGE_TYPE=unknown",
"KERNEL_INSTALL_MACHINE_ID=3e0484f3634a418b8e6a39e8828b03e3", "KERNEL_INSTALL_MACHINE_ID=3e0484f3634a418b8e6a39e8828b03e3",

View File

@ -132,7 +132,7 @@ _sd_const_ static __inline__ int sd_id128_is_allf(sd_id128_t a) {
#define SD_ID128_NULL ((const sd_id128_t) { .qwords = { 0, 0 }}) #define SD_ID128_NULL ((const sd_id128_t) { .qwords = { 0, 0 }})
#define SD_ID128_ALLF ((const sd_id128_t) { .qwords = { UINT64_C(0xFFFFFFFFFFFFFFFF), UINT64_C(0xFFFFFFFFFFFFFFFF) }}) #define SD_ID128_ALLF ((const sd_id128_t) { .qwords = { UINT64_C(0xFFFFFFFFFFFFFFFF), UINT64_C(0xFFFFFFFFFFFFFFFF) }})
_sd_const_ static __inline__ int sd_id128_in_setv(sd_id128_t a, va_list ap) { static __inline__ int sd_id128_in_setv(sd_id128_t a, va_list ap) {
for (;;) { for (;;) {
sd_id128_t b = va_arg(ap, sd_id128_t); sd_id128_t b = va_arg(ap, sd_id128_t);

View File

@ -14,6 +14,7 @@ path = run_command(sh, '-c', 'echo "$PATH"', check: true).stdout().strip()
test_env = { test_env = {
'PATH' : meson.project_build_root() + ':' + path, 'PATH' : meson.project_build_root() + ':' + path,
'PROJECT_BUILD_ROOT' : meson.project_build_root(), 'PROJECT_BUILD_ROOT' : meson.project_build_root(),
'SYSTEMD_DEFAULT_LOCALE' : get_option('default-locale'),
'SYSTEMD_SLOW_TESTS' : want_slow_tests ? '1' : '0', 'SYSTEMD_SLOW_TESTS' : want_slow_tests ? '1' : '0',
'PYTHONDONTWRITEBYTECODE' : '1', 'PYTHONDONTWRITEBYTECODE' : '1',
} }
@ -275,6 +276,17 @@ executables += [
'sources' : files('test-compress.c'), 'sources' : files('test-compress.c'),
'link_with' : [libshared], 'link_with' : [libshared],
}, },
test_template + {
'sources' : files('test-coredump-stacktrace.c'),
'type' : 'manual',
# This test intentionally crashes with SIGSEGV by dereferencing a NULL pointer
# to generate a coredump with a predictable stack trace. To prevent sanitizers
# from catching the error first let's disable them explicitly, and also always
# build with minimal optimizations to make the stack trace predictable no matter
# what we build the rest of systemd with
'override_options' : ['b_sanitize=none', 'strip=false', 'debug=true'],
'c_args' : ['-fno-sanitize=all', '-fno-optimize-sibling-calls', '-O1'],
},
test_template + { test_template + {
'sources' : files('test-cryptolib.c'), 'sources' : files('test-cryptolib.c'),
'dependencies' : libopenssl, 'dependencies' : libopenssl,

View File

@ -0,0 +1,29 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* This is a test program that intentionally segfaults so we can generate a
* predictable-ish stack trace in tests. */
#include <stdlib.h>
__attribute__((noinline))
static void baz(int *x) {
*x = rand();
}
__attribute__((noinline))
static void bar(void) {
int * volatile x = NULL;
baz(x);
}
__attribute__((noinline))
static void foo(void) {
bar();
}
int main(void) {
foo();
return 0;
}

View File

@ -5,7 +5,7 @@ integration_tests += [
integration_test_template + { integration_test_template + {
'name' : fs.name(meson.current_source_dir()), 'name' : fs.name(meson.current_source_dir()),
'storage': 'persistent', 'storage': 'persistent',
'coredump-exclude-regex' : '/(test-usr-dump|test-dump|bash)$', 'coredump-exclude-regex' : '/(test-usr-dump|test-dump|test-stacktrace(-not)?-symbolized|bash)$',
'vm' : true, 'vm' : true,
'firmware' : 'auto', 'firmware' : 'auto',
}, },

View File

@ -8,15 +8,13 @@ set -o pipefail
# Make sure the binary name fits into 15 characters # Make sure the binary name fits into 15 characters
CORE_TEST_BIN="/tmp/test-dump" CORE_TEST_BIN="/tmp/test-dump"
CORE_STACKTRACE_TEST_BIN="/tmp/test-stacktrace-dump"
MAKE_STACKTRACE_DUMP="/tmp/make-stacktrace-dump"
CORE_TEST_UNPRIV_BIN="/tmp/test-usr-dump" CORE_TEST_UNPRIV_BIN="/tmp/test-usr-dump"
MAKE_DUMP_SCRIPT="/tmp/make-dump" MAKE_DUMP_SCRIPT="/tmp/make-dump"
# Unset $PAGER so we don't have to use --no-pager everywhere # Unset $PAGER so we don't have to use --no-pager everywhere
export PAGER= export PAGER=
at_exit() { at_exit() {
rm -fv -- "$CORE_TEST_BIN" "$CORE_TEST_UNPRIV_BIN" "$MAKE_DUMP_SCRIPT" "$MAKE_STACKTRACE_DUMP" rm -fv -- "$CORE_TEST_BIN" "$CORE_TEST_UNPRIV_BIN" "$MAKE_DUMP_SCRIPT"
} }
(! systemd-detect-virt -cq) (! systemd-detect-virt -cq)
@ -251,30 +249,70 @@ systemd-run -t --property CoredumpFilter=default ls /tmp
(! coredumpctl debug --debugger=/bin/true --debugger-arguments='"') (! coredumpctl debug --debugger=/bin/true --debugger-arguments='"')
# Test for EnterNamespace= feature # Test for EnterNamespace= feature
if pkgconf --atleast-version 0.192 libdw ; then #
# dwfl_set_sysroot() is supported only in libdw-0.192 or newer. # dwfl_set_sysroot() is supported only in libdw-0.192 or newer.
cat >"$MAKE_STACKTRACE_DUMP" <<END #
#!/usr/bin/env bash # FIXME: drop the objdump call once https://github.com/systemd/systemd/pull/39268#issuecomment-3390745718 is
mount -t tmpfs tmpfs /tmp # addressed
gcc -xc -O0 -g -o $CORE_STACKTRACE_TEST_BIN - <<EOF if pkgconf --atleast-version 0.192 libdw &&
void baz(void) { int *x = 0; *x = 42; } objdump -h -j .gnu_debugdata -j .debug_info /usr/lib/systemd/tests/unit-tests/manual/test-coredump-stacktrace; then
void bar(void) { baz(); } MAKE_STACKTRACE_DUMP="/tmp/make-stacktrace-dump"
void foo(void) { bar(); }
int main(void) { foo(); return 0;} # Simple script that mounts tmpfs on /tmp/ and copies the crashing test binary there, which in
# combination with `unshare --mount` ensures the "outside" systemd-coredump process won't be able to
# access the crashed binary (and hence won't be able to symbolize its stacktrace) unless
# EnterNamespace=yes is used
cat >"$MAKE_STACKTRACE_DUMP" <<\EOF
#!/usr/bin/bash -eux
TARGET="/tmp/${1:?}"
EC=0
# "Unhide" debuginfo in the namespace (see the comment below)
test -d /usr/lib/debug/ && umount /usr/lib/debug/
mount -t tmpfs tmpfs /tmp/
cp /usr/lib/systemd/tests/unit-tests/manual/test-coredump-stacktrace "$TARGET"
$TARGET || EC=$?
if [[ $EC -ne 139 ]]; then
echo >&2 "$TARGET didn't crash, this shouldn't happen"
exit 1
fi
exit 0
EOF EOF
$CORE_STACKTRACE_TEST_BIN
END
chmod +x "$MAKE_STACKTRACE_DUMP" chmod +x "$MAKE_STACKTRACE_DUMP"
# Since the test-coredump-stacktrace binary is built together with rest of the systemd its debug symbols
# might be part of debuginfo packages (if supported & built), and libdw will then use them to symbolize
# the stacktrace even if it doesn't have access to the original crashing binary. Let's make the test
# simpler and just "hide" the debuginfo data, so libdw is forced to access the target namespace to get
# the necessary symbols
test -d /usr/lib/debug/ && mount -t tmpfs tmpfs /usr/lib/debug/
mkdir -p /run/systemd/coredump.conf.d/ mkdir -p /run/systemd/coredump.conf.d/
printf '[Coredump]\nEnterNamespace=no' >/run/systemd/coredump.conf.d/99-enter-namespace.conf printf '[Coredump]\nEnterNamespace=no' >/run/systemd/coredump.conf.d/99-enter-namespace.conf
unshare --pid --fork --mount-proc --mount --uts --ipc --net bash -c "$MAKE_STACKTRACE_DUMP" || : unshare --pid --fork --mount-proc --mount --uts --ipc --net "$MAKE_STACKTRACE_DUMP" "test-stacktrace-not-symbolized"
timeout 30 bash -c "until coredumpctl -1 info $CORE_STACKTRACE_TEST_BIN | grep -zvqE 'baz.*bar.*foo'; do sleep .2; done" timeout 30 bash -c "until coredumpctl list -q --no-legend /tmp/test-stacktrace-not-symbolized; do sleep .2; done"
coredumpctl info /tmp/test-stacktrace-not-symbolized | tee /tmp/not-symbolized.log
(! grep -E "#[0-9]+ .* main " /tmp/not-symbolized.log)
(! grep -E "#[0-9]+ .* foo " /tmp/not-symbolized.log)
(! grep -E "#[0-9]+ .* bar " /tmp/not-symbolized.log)
(! grep -E "#[0-9]+ .* baz " /tmp/not-symbolized.log)
printf '[Coredump]\nEnterNamespace=yes' >/run/systemd/coredump.conf.d/99-enter-namespace.conf printf '[Coredump]\nEnterNamespace=yes' >/run/systemd/coredump.conf.d/99-enter-namespace.conf
unshare --pid --fork --mount-proc --mount --uts --ipc --net bash -c "$MAKE_STACKTRACE_DUMP" || : unshare --pid --fork --mount-proc --mount --uts --ipc --net "$MAKE_STACKTRACE_DUMP" "test-stacktrace-symbolized"
timeout 30 bash -c "until coredumpctl -1 info $CORE_STACKTRACE_TEST_BIN | grep -zqE 'baz.*bar.*foo'; do sleep .2; done" timeout 30 bash -c "until coredumpctl list -q --no-legend /tmp/test-stacktrace-symbolized; do sleep .2; done"
coredumpctl info /tmp/test-stacktrace-symbolized | tee /tmp/symbolized.log
grep -E "#[0-9]+ .* main " /tmp/symbolized.log
grep -E "#[0-9]+ .* foo " /tmp/symbolized.log
grep -E "#[0-9]+ .* bar " /tmp/symbolized.log
grep -E "#[0-9]+ .* baz " /tmp/symbolized.log
test -d /usr/lib/debug/ && umount /usr/lib/debug/
rm -f "$MAKE_STACKTRACE_DUMP" /run/systemd/coredump.conf.d/99-enter-namespace.conf /tmp/{not-,}symbolized.log
else else
echo "libdw doesn't not support setting sysroot, skipping EnterNamespace= test" echo "libdw doesn't not support setting sysroot, skipping EnterNamespace= test"
fi fi