teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0258-test-initialize-syslog_fd-in-fuzz-journald-kmsg-too.patch

Brian Stinson 2593d8
From af471e7402a70b670cd50e45c6139a0ac50a74bd Mon Sep 17 00:00:00 2001
Brian Stinson 2593d8
From: Evgeny Vereshchagin <evvers@ya.ru>
Brian Stinson 2593d8
Date: Fri, 16 Nov 2018 09:23:53 +0100
Brian Stinson 2593d8
Subject: [PATCH] test: initialize syslog_fd in fuzz-journald-kmsg too
Brian Stinson 2593d8
Brian Stinson 2593d8
This is a follow-up to 8857fb9beb9dcb that prevents the fuzzer from crashing with
Brian Stinson 2593d8
```
Brian Stinson 2593d8
==220==ERROR: AddressSanitizer: ABRT on unknown address 0x0000000000dc (pc 0x7ff4953c8428 bp 0x7ffcf66ec290 sp 0x7ffcf66ec128 T0)
Brian Stinson 2593d8
SCARINESS: 10 (signal)
Brian Stinson 2593d8
    #0 0x7ff4953c8427 in gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35427)
Brian Stinson 2593d8
    #1 0x7ff4953ca029 in abort (/lib/x86_64-linux-gnu/libc.so.6+0x37029)
Brian Stinson 2593d8
    #2 0x7ff49666503a in log_assert_failed_realm /work/build/../../src/systemd/src/basic/log.c:805:9
Brian Stinson 2593d8
    #3 0x7ff496614ecf in safe_close /work/build/../../src/systemd/src/basic/fd-util.c:66:17
Brian Stinson 2593d8
    #4 0x548806 in server_done /work/build/../../src/systemd/src/journal/journald-server.c:2064:9
Brian Stinson 2593d8
    #5 0x5349fa in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-journald-kmsg.c:26:9
Brian Stinson 2593d8
    #6 0x592755 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:571:15
Brian Stinson 2593d8
    #7 0x590627 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:480:3
Brian Stinson 2593d8
    #8 0x594432 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:708:19
Brian Stinson 2593d8
    #9 0x5973c6 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:839:5
Brian Stinson 2593d8
    #10 0x574541 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
Brian Stinson 2593d8
    #11 0x5675fc in main /src/libfuzzer/FuzzerMain.cpp:20:10
Brian Stinson 2593d8
    #12 0x7ff4953b382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
Brian Stinson 2593d8
    #13 0x420f58 in _start (/out/fuzz-journald-kmsg+0x420f58)
Brian Stinson 2593d8
```
Brian Stinson 2593d8
Brian Stinson 2593d8
(cherry picked from commit cc55ac0171a2493768c021faa356513642797e7f)
Brian Stinson 2593d8
Brian Stinson 2593d8
Resolves: #1764560
Brian Stinson 2593d8
---
Brian Stinson 2593d8
 src/fuzz/fuzz-journald-kmsg.c | 1 +
Brian Stinson 2593d8
 1 file changed, 1 insertion(+)
Brian Stinson 2593d8
Brian Stinson 2593d8
diff --git a/src/fuzz/fuzz-journald-kmsg.c b/src/fuzz/fuzz-journald-kmsg.c
Brian Stinson 2593d8
index 5d99d244b5..e2611c6d45 100644
Brian Stinson 2593d8
--- a/src/fuzz/fuzz-journald-kmsg.c
Brian Stinson 2593d8
+++ b/src/fuzz/fuzz-journald-kmsg.c
Brian Stinson 2593d8
@@ -11,6 +11,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Brian Stinson 2593d8
                 return 0;
Brian Stinson 2593d8
 
Brian Stinson 2593d8
         s = (Server) {
Brian Stinson 2593d8
+                .syslog_fd = -1,
Brian Stinson 2593d8
                 .native_fd = -1,
Brian Stinson 2593d8
                 .stdout_fd = -1,
Brian Stinson 2593d8
                 .dev_kmsg_fd = -1,