Commit Graph

102 Commits

Author SHA1 Message Date
Yu Watanabe 57dda0de38 fuzzers: set maximum length for several fuzzers
Hopefully fixes oss-fuzz#19081, oss-fuzz#21731, oss-fuzz#21755.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19081
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21731
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21755
2020-12-30 00:31:17 +09:00
Zbigniew Jędrzejewski-Szmek e2054217d5 Move hostname setup logic to new shared/hostname-setup.[ch]
No functional change, just moving a bunch of things around. Before
we needed a rather complicated setup to test hostname_setup(), because
the code was in src/core/. When things are moved to src/shared/
we can just test it as any function.

The test is still "unsafe" because hostname_setup() may modify the
hostname.
2020-12-16 11:02:15 +01:00
Yu Watanabe e4b127e2cc meson: do not link with libudev 2020-12-16 02:31:44 +09:00
Yu Watanabe 0d5eb02134
Merge pull request #17478 from yuwata/split-network-internal
libsystemd-network: split network-internal.c
2020-11-27 09:04:19 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Yu, Li-Yu c32d562da5 udev: add fuzzer for udev_rule_parse_value 2020-10-29 20:19:29 +08:00
Yu Watanabe 26f4d32365 meson: drop libsystemd_network from several binaries
This reduces the size of udevadm:

Before:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1203800 Oct 29 01:36 udevadm
```

After:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1094384 Oct 29 01:38 udevadm
```
2020-10-29 14:23:49 +09:00
Zbigniew Jędrzejewski-Szmek f23810da20 fuzz-udev-rules: -ENOBUFS should be accepted too
In udev_rules_load(), add a debug message. Otherwise there'd be no indication
that parsing was aborted.
2020-06-25 08:51:21 +02:00
Zbigniew Jędrzejewski-Szmek db3b8d5d41 fuzz-udev-rules: rewrite to not require root privileges
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20142.

It turns out we don't need to do all this preparatory work if we want to parse
just one file.
2020-06-23 20:53:19 +02:00
Zbigniew Jędrzejewski-Szmek c238a1f5f1 udev: split rules object creation and loading
The only functional change is to downgrade the log line to avoid double
logging.
2020-06-23 18:04:18 +02:00
Lennart Poettering 7ade8982ca core: remove support for ".include" stanza
Six years ago we declared it obsolete and removed it from the docs
(c073a0c4a5) and added a note about it in
NEWS. Two years ago we add warning messages about it, indicating the
feature will be removed (41b283d0f1) and
mentioned it in NEWS again.

Let's now kill it for good.
2020-06-03 18:26:12 +02:00
Lennart Poettering 4f9ff96a55 conf-parser: return mtime in config_parse() and friends
This is a follow-up for 9f83091e3c.

Instead of reading the mtime off the configuration files after reading,
let's do so before reading, but with the fd we read the data from. This
is not only cleaner (as it allows us to save one stat()), but also has
the benefit that we'll detect changes that happen while we read the
files.

This also reworks unit file drop-ins to use the common code for
determining drop-in mtime, instead of reading system clock for that.
2020-06-02 19:32:20 +02:00
Lennart Poettering 6527b019fc xdg-autostart: fix two coverity found issues
Fixes: CID#1429003
Fixes: CID#1429004
2020-05-28 23:38:38 +02:00
Benjamin Berg 2ad7597e44 fuzz: Add an XDG desktop file fuzzer
To test the XDG parser used by the xdg-autostart-generator.

Co-authored-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-05-27 09:02:10 +02:00
Evgeny Vereshchagin 6b8d32ea7b ci: turn off FuzzBuzz
I don't think anyone uses it.
2020-03-30 14:57:22 +02:00
Zbigniew Jędrzejewski-Szmek 2b4a65b668 sd-bus: export sd_bus_message_dump
Fixes #14640.
2020-01-23 23:38:20 +01:00
Zbigniew Jędrzejewski-Szmek 27cf4c18c7 sd-bus: make dump flags public 2020-01-23 23:38:20 +01:00
Lennart Poettering d642f640bf json: add flags parameter to json_parse_file(), for parsing "sensitive" data
This will call json_variant_sensitive() internally while parsing for
each allocated sub-variant. This is better than calling it a posteriori
at the end, because partially parsed variants will always be properly
erased from memory this way.
2019-12-02 09:47:00 +01:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Yu Watanabe 9648956d1f test: move {test,fuzz}-fido-id-desc.c into src/udev/fido_id 2019-10-31 10:37:42 +09:00
Fabian Henneke d45ee2f31a udev: Add id program and rule for FIDO security tokens
Add a fido_id program meant to be run for devices in the hidraw
subsystem via an IMPORT directive. The program parses the HID report
descriptor and assigns the ID_SECURITY_TOKEN environment variable if a
declared usage matches the FIDO_CTAPHID_USAGE declared in the FIDO CTAP
specification. This replaces the previous approach of whitelisting all
known security token models manually.

This commit is accompanied by a test suite and a fuzzer target for the
descriptor parsing routine.

Fixes: #11996.
2019-09-07 02:23:58 +09:00
Daniel Edgecumbe a95686bb5d journal: Make the output of --update-catalog deterministic
The use of an unordered hashmap means that the output of
'journalctl --update-catalog' differs between runs despite there being no
changes in the input files.

By changing all instances of Hashmap to OrderedHashmap we fix this, and now
the catalog is reproducible.

Motivation: https://reproducible-builds.org

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
2019-09-06 15:13:54 +02:00
Yu Watanabe 25de7aa7b9 udev: modernize udev-rules.c
This does the following:
- rename enum udev_builtin_cmd -> UdevBuiltinCmd
- rename struct udev_builtin -> UdevBuiltin
- move type definitions to udev-rules.h
- move prototypes of functions defined in udev-rules.c to udev-rules.h
- drop to use strbuf
- propagate critical errors in applying rules,
- drop limitation for number of tokens per line.
2019-06-02 14:15:26 +09:00
Lennart Poettering d768467563 fuzzer: add varlink fuzzer 2019-05-09 14:14:20 -04:00
Evgeny Vereshchagin 87ac55a129 tests: hook up fuzz targets to FuzzBuzz 2019-05-07 21:39:01 +00:00
Franck Bui 9f3f596477 meson: make source files including nspawn-settings.h depend on libseccomp
Since nspawn-settings.h includes seccomp.h, any file that includes
nspawn-settings.h should depend on libseccomp so the correct header path where
seccomp.h lives is added to the header search paths.

It's especially important for distros such as openSUSE where seccomp.h is not
shipped in /usr/include but /usr/include/libseccomp.

This patch is similar to 8238423095.
2019-04-30 19:31:22 +02:00
Zbigniew Jędrzejewski-Szmek 673a1e6fb9 Add fmemopen_unlocked() and use unlocked ops in fuzzers and some other tests
This might make things marginially faster. I didn't benchmark though.
2019-04-12 11:44:57 +02:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
This means we need to include many more headers in various files that simply
included util.h before, but it seems cleaner to do it this way.
2019-03-27 11:53:12 +01:00
Zbigniew Jędrzejewski-Szmek 9ddd62cda1 fuzz-nspawn-oci: add fuzzer for the oci bundle loader 2019-03-22 11:09:52 +01:00
Zbigniew Jędrzejewski-Szmek bcaabf481d fuzz-calendarspec: actually run the second part of the fuzzer
https://github.com/systemd/systemd/pull/11975#issuecomment-473467475
2019-03-16 18:13:17 +01:00
Lennart Poettering d449d63a0d
Merge pull request #11975 from keszybz/fuzzer-fixes-n
Fixes for a few fuzzer issues
2019-03-15 17:34:37 +01:00
Lennart Poettering 0a9707187b util: split out memcmp()/memset() related calls into memory-util.[ch]
Just some source rearranging.
2019-03-13 12:16:43 +01:00
Zbigniew Jędrzejewski-Szmek 0fb729282b fuzz: limit the maximum size of test inputs for a few parsers
We have a few cases or reported issues which are about a timeout to parse
the input in 25 s. In all cases, the input is a few hundred kb. We don't really
care if the config parsers are super efficent, so let's set a limit on the input
size to avoid triggering such issues. The parsers often contain quadratic
algorithms. This is OK, because the numbers of elements are almost always very
small in real use. Rewriting the code to use more complicated data structures
to speed this up would not only complicate the code, but also pessimize behaviour
for the overwhelmingly common case of small samples. Note that in all those
cases, the input data is trusted. We care about memory correctness, and not
not so much about efficiency.

The size checks are done twice: using options for libfuzzer, and using an
internal check for afl. Those should be changed together. I didn't use a define,
because there is no easy mechanism to share the define between the two files.
2019-03-12 19:30:05 +01:00
Frantisek Sumsal 55a365cb74 fuzz: add a fuzzer for time utils 2019-03-12 12:04:25 +01:00
Frantisek Sumsal 415b3f0bb2 fuzz: add a fuzzer for calendarspec 2019-03-12 11:57:09 +01:00
Frantisek Sumsal b5b499b32c fuzz: add nspawn-settings fuzzer 2019-03-11 14:13:00 +01:00
Frantisek Sumsal 04ddab1462 fuzz: add hostname-util fuzzer 2019-03-11 14:12:06 +01:00
Frantisek Sumsal 18d51b4509 fuzz: add env-file fuzzer 2019-03-11 14:11:28 +01:00
Frantisek Sumsal e5f274bee1 fuzz: add bus-label fuzzer 2019-03-11 13:00:32 +01:00
Yu Watanabe 55ac7b6314 fuzz-dhcp6-client: avoid assertion failure on samples which dont fit in pipe
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11584.
2019-03-04 12:04:09 +01:00
Yu Watanabe 358fb6862b fuzz: do not assume the existence of /sys/class/net/lo
Hopefully fixes oss-fuzz#13440.
2019-02-28 10:38:16 +01:00
Lennart Poettering f3892edd5e
Merge pull request #11824 from keszybz/fuzzer-fixes
Fuzzer fixes
2019-02-26 19:02:12 +01:00
Lennart Poettering 8c28360a21
Merge pull request #11823 from keszybz/more-fuzz-coverage
More fuzz coverage
2019-02-26 17:21:32 +01:00
Zbigniew Jędrzejewski-Szmek 9b7f73b03f fuzz-ndisc-rs: avoid assertion failure on samples which dont fit in pipe
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11605.
2019-02-26 13:14:56 +01:00
Zbigniew Jędrzejewski-Szmek d92e7b8fe4 fuzz-lldp: avoid assertion failure on samples which dont fit in pipe
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11603.
2019-02-26 13:13:02 +01:00
Zbigniew Jędrzejewski-Szmek eafadd069c fuzz-journal-stream: avoid assertion failure on samples which don't fit in pipe
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11587.
We had a sample which was large enough that write(2) failed to push all the
data into the pipe, and an assert failed. The code could be changed to use
a loop, but then we'd need to interleave writes and sd_event_run (to process
the journal). I don't think the complexity is worth it — fuzzing works best
if the sample is not too huge anyway. So let's just reject samples above 64k,
and tell oss-fuzz about this limit.
2019-02-26 13:00:35 +01:00
Yu Watanabe 4c9024c2cf fuzz: add fuzzer for udev database 2019-02-26 13:10:31 +09:00
Zbigniew Jędrzejewski-Szmek 4832ce7eec fuzz-unit-file: also run manager_dump()
This should increase coverage a bit.
2019-02-25 15:46:23 +01:00
Zbigniew Jędrzejewski-Szmek 9a07157dd5 udev: use typedef for struct udev_rules 2018-12-17 09:27:21 +01:00
Zbigniew Jędrzejewski-Szmek 1d79128121 udev: make udev_rules_new() return a proper error code 2018-12-14 10:20:43 +01:00