From 112cc3b5b2f61475afed6b082e917001710470bf Mon Sep 17 00:00:00 2001 From: Evegeny Vereshchagin Date: Fri, 9 Mar 2018 00:44:57 +0000 Subject: [PATCH 1/3] tests: skip the rest of test_mnt_id after getting any error This mainly gets around a kernel bug making it possible to have non-existent paths in /proc/self/mountinfo, but it should also prevent flaky failures that can happen if something changes immediately after or during reading /proc/self/mountinfo. Closes https://github.com/systemd/systemd/issues/8286. --- src/test/test-mount-util.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c index c95baa81a71..5f2ad7c7194 100644 --- a/src/test/test-mount-util.c +++ b/src/test/test-mount-util.c @@ -80,12 +80,8 @@ static void test_mnt_id(void) { int mnt_id = PTR_TO_INT(k), mnt_id2; r = path_get_mnt_id(p, &mnt_id2); - if (r == -EOPNOTSUPP) { /* kernel or file system too old? */ - log_debug("%s doesn't support mount IDs\n", p); - continue; - } - if (IN_SET(r, -EACCES, -EPERM)) { - log_debug("Can't access %s\n", p); + if (r < 0) { + log_debug_errno(r, "Failed to get the mnt id of %s: %m\n", p); continue; } From c58fd466a313a1f93df1792822e358c67990bcdf Mon Sep 17 00:00:00 2001 From: Evegeny Vereshchagin Date: Fri, 9 Mar 2018 01:10:42 +0000 Subject: [PATCH 2/3] tests: make / private after creating a mount namespace so that the test never affects the root namespace. --- src/test/test-process-util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 0e5a9d811d7..1a0164e601f 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -193,6 +193,8 @@ static void test_get_process_cmdline_harder(void) { assert_se(pid == 0); assert_se(unshare(CLONE_NEWNS) >= 0); + assert_se(mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL) >= 0); + fd = mkostemp(path, O_CLOEXEC); assert_se(fd >= 0); From c8d980a3e962aba2ea3a4cedf75fa94890a6d746 Mon Sep 17 00:00:00 2001 From: Evegeny Vereshchagin Date: Fri, 9 Mar 2018 14:51:45 +0000 Subject: [PATCH 3/3] tests: skip g_dbus_message_new_from_blob under asan Some versions of asan report the following false positive when strict_string_checks=1 is passed: ================================================================= ==3297==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f64e4090286 bp 0x7ffe46acd9a0 sp 0x7ffe46acd118 T0) ==3297==The signal is caused by a READ memory access. ==3297==Hint: address points to the zero page. #0 0x7f64e4090285 in __strlen_sse2 (/lib64/libc.so.6+0xaa285) #1 0x7f64e5a51e46 (/lib64/libasan.so.4+0x41e46) #2 0x7f64e4e5e3a0 (/lib64/libglib-2.0.so.0+0x383a0) #3 0x7f64e4e5e536 in g_dgettext (/lib64/libglib-2.0.so.0+0x38536) #4 0x7f64e48fac5f (/lib64/libgio-2.0.so.0+0xc1c5f) #5 0x7f64e4c03978 in g_type_class_ref (/lib64/libgobject-2.0.so.0+0x30978) #6 0x7f64e4be9567 in g_object_new_with_properties (/lib64/libgobject-2.0.so.0+0x16567) #7 0x7f64e4be9fd0 in g_object_new (/lib64/libgobject-2.0.so.0+0x16fd0) #8 0x7f64e48fd43e in g_dbus_message_new_from_blob (/lib64/libgio-2.0.so.0+0xc443e) #9 0x564a6aa0de52 in main ../src/libsystemd/sd-bus/test-bus-marshal.c:228 #10 0x7f64e4007009 in __libc_start_main (/lib64/libc.so.6+0x21009) #11 0x564a6aa0a569 in _start (/home/vagrant/systemd/build/test-bus-marshal+0x5569) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV (/lib64/libc.so.6+0xaa285) in __strlen_sse2 ==3297==ABORTING It's an external library and errors in external libraries are generally not very useful for looking for internal bugs. It would be better not to change the code and use standard suppression techinques decribed at https://clang.llvm.org/docs/AddressSanitizer.html#suppressing-reports-in-external-libraries, but, unfortunaley, none of them seems to be able to suppress fatal errors in asan intself. --- src/libsystemd/sd-bus/test-bus-marshal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c index ebf55e873cc..8c80b501248 100644 --- a/src/libsystemd/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/sd-bus/test-bus-marshal.c @@ -217,6 +217,7 @@ int main(int argc, char *argv[]) { free(h); #if HAVE_GLIB +#ifndef __SANITIZE_ADDRESS__ { GDBusMessage *g; char *p; @@ -232,6 +233,7 @@ int main(int argc, char *argv[]) { g_object_unref(g); } #endif +#endif #if HAVE_DBUS {