Yu Watanabe
4ca5acb35f
ipv4acd: use structured initializer at one more place
2018-11-16 22:57:42 +09:00
Yu Watanabe
c9393e8c41
dhcp6-client: do not unref() event sources when update or disable them
2018-11-16 22:57:42 +09:00
Yu Watanabe
8b8ecac85b
dhcp6-client: use structured initializer at one more place
2018-11-16 22:57:42 +09:00
Benjamin Berg
a5f07d2a16
sd-dhcp6: fix crash by unrefing event sources before re-adding them
...
In certain cases the timeouts may not have been unref'ed before they
need to be re-added. Add the appropriate unref calls to ensure we don't
register the timeout multiple times.
This fixes possible cases where timeouts are triggered multiple times
and even on destroyed DHCPv6 clients.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/73
Fixes #10749 .
2018-11-16 22:57:42 +09:00
Yu Watanabe
a3fa4287f5
dhcp-client: do not unref() event sources when update or disable them
2018-11-16 22:57:42 +09:00
Yu Watanabe
be6bf4a786
dhcp-client: use structured initializer at one more place
2018-11-16 22:57:42 +09:00
Lennart Poettering
13df9c398d
fileio: automatically add NULL sentinel to parse_env_file()
...
Let's modernize things a bit.
2018-11-14 17:01:55 +01:00
Lennart Poettering
aa8fbc74e3
fileio: drop "newline" parameter for env file parsers
...
Now that we don't (mis-)use the env file parser to parse kernel command
lines there's no need anymore to override the used newline character
set. Let's hence drop the argument and just "\n\r" always. This nicely
simplifies our code.
2018-11-14 17:01:54 +01:00
Thomas Haller
6d13616b9e
dhcp: support endianness independent dhcp_identifier_set_iaid()
...
The previous code did htole64() followed by unaligned_write_be32() (the
XOR and shift in between is endianness agnostic). That means, on every
architeture there is always exactly one byte swap and the iaid is
dependent on endianness.
Since dhcp_identifier_set_iaid() is part of the DUID generation
algorithm, this cannot be fixed without changing the client-id.
In particular, as the client-id already depends on the machine-id (and
is thus inherrently host-specific), it is better to stick to the current
behavior.
However, add a parameter to switch between old and new behaviour.
Since the new behavior is unused, the only real purpose of this
change is to self-document the oddity of the function.
Fixes: 933f9caeeb
2018-11-12 19:08:35 +01:00
Thomas Haller
43fc095532
dhcp: add test for dhcp_identifier_set_iaid()
2018-11-12 19:08:35 +01:00
Yu Watanabe
3e29b8895a
libsystemd-network: set SOCK_CLOEXEC and SOCK_NONBLOCK
2018-11-12 02:03:22 +09:00
Yu Watanabe
a2dcda328a
ndisc: improve debug log message
2018-11-06 20:15:09 +09:00
Yu Watanabe
4f0e4d29b0
lldp: improve debug log message
2018-11-06 20:15:09 +09:00
Yu Watanabe
899f0d259d
network: fix memleak in config_parse_hwaddr()
...
Fixes #10615 .
2018-11-04 00:31:46 +09:00
Yu Watanabe
44386b449b
network: improve readability of config_parse_ifalias()
2018-11-04 00:31:46 +09:00
Yu Watanabe
5a937ea2f6
sd-device: make sd_device_get_is_initialized() returns is_initialized by return value
2018-10-29 17:33:33 +09:00
Lennart Poettering
20b55f8538
dhcp6: prefer offsetof() over sizeof() for structs with undefined sizes
...
This doesn't change anything in the generated source, but I think makes
semantically more sense, as these structures have undefined size, and we
only want to know the size up to the data field in these cases.
2018-10-25 11:23:19 +02:00
Lennart Poettering
4dac5eaba4
dhcp6: make sure we have enough space for the DHCP6 option header
...
Fixes a vulnerability originally discovered by Felix Wilhelm from
Google.
CVE-2018-15688
LP: #1795921
https://bugzilla.redhat.com/show_bug.cgi?id=1639067
2018-10-25 11:23:19 +02:00
Lennart Poettering
990668aa4c
dhcp6: reduce whitespace a bit
2018-10-25 11:23:19 +02:00
Lennart Poettering
3c290c0316
dhcp6: split assert_return() to be more debuggable when hit
2018-10-25 11:23:19 +02:00
Lennart Poettering
e0a18b74a3
dhcp6: constify things where we can
2018-10-25 11:23:19 +02:00
Li Song
cc3981b127
sd-dhcp: remove unreachable route after rebinding return NAK
2018-10-19 22:59:20 +02:00
Yu Watanabe
14cb109d45
tree-wide: replace 'unsigned int' with 'unsigned'
2018-10-19 22:19:12 +02:00
Lennart Poettering
a4544f53c4
Merge pull request #10457 from yuwata/fuzz-11019
...
sd-dhcp: fixes oss-fuzz#11019 and several cleanups
2018-10-19 10:48:41 +02:00
Yu Watanabe
aae1fa5cc8
sd-dhcp6: drop empty 'error' label
2018-10-19 06:11:58 +09:00
Yu Watanabe
9a25416479
test-dhcp6-client: normalize logs
2018-10-19 06:11:58 +09:00
Yu Watanabe
3c72b6ed42
sd-dhcp6: make dhcp6_option_parse_domainname() not store empty domain
...
This improves performance of fuzzer.
C.f. oss-fuzz#11019.
2018-10-19 06:11:58 +09:00
Yu Watanabe
33d3675895
sd-dhcp6: do not update serverid when ENOMEM
2018-10-19 06:11:58 +09:00
Yu Watanabe
da07cf3582
sd-dhcp6: coding style cleanups
2018-10-19 06:11:58 +09:00
Yu Watanabe
91c43f3978
sd-dhcp6: fix argument and error handling of dhcp6_option_parse_status()
2018-10-19 06:11:58 +09:00
Yu Watanabe
9e5b649655
tree-wide: use setsockopt_int() more
2018-10-19 05:52:42 +09:00
Lennart Poettering
2ff48e981e
tree-wide: introduce setsockopt_int() helper and make use of it everywhere
...
As suggested by @heftig:
https://github.com/systemd/systemd/commit/6d5e65f6454212cd400d0ebda34978a9f20cc26a#commitcomment-30938667
2018-10-18 19:50:29 +02:00
Lennart Poettering
6d5e65f645
tree-wide: add a single version of "static const int one = 1"
...
All over the place we define local variables for the various sockopts
that take a bool-like "int" value. Sometimes they are const, sometimes
static, sometimes both, sometimes neither.
Let's clean this up, introduce a common const variable "const_int_one"
(as well as one matching "const_int_zero") and use it everywhere, all
acorss the codebase.
2018-10-15 19:40:51 +02:00
Lennart Poettering
165ad41b7f
sd-ndisc: change return value of ndisc_reset() to void
...
We never generate anything other than 0 anyway, and we never check it,
hence let's just simplify things.
2018-10-13 12:37:13 +02:00
Lennart Poettering
76f713dfa4
sd-ndisc: voidify sd_ndisc_stop() call
...
CID 1395839
2018-10-13 12:37:13 +02:00
Thomas Haller
b62f900866
dhcp6: don't include internal header "sparse-endian.h" in "sd-dhcp6-client.h"
...
Arguably, libsystemd-network is (still) entirely internal API.
However there is the aim of maybe exposing it as public API.
For that reason, it cannot include internal headers from
"src/basic/".
Note how files "src/systemd/sd-*.h" don't include any systemd
headers which don't themself have an "sd-" prefix.
Fixes: d89a400ed6
2018-10-04 21:29:35 +02:00
Yu Watanabe
84452783b8
dhcp6: check option length before reading values
...
Fixes oss-fuzz#10746
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10746 .
2018-10-03 08:49:55 +09:00
Lennart Poettering
8eb41f4c08
sd-radv: EAGAIN is not really unexpected, distinguishit from other errors when logging
2018-10-02 16:26:50 +02:00
Lennart Poettering
437524f178
sd-ndisc: generate debug log messages on unexpected errors
...
We really should make it possible to debug unexpected errors, hence log
something at LOG_DEBUG.
2018-10-02 16:25:54 +02:00
Lennart Poettering
fdc2afc102
sd-radv: remove log_radv_warning_errno()
...
According to our CODING_STYLE our library code should generally not log
beyond LOG_DEBUG. Let's hence get rid of log_radv_warning_errno() and
just use log_radv_errno() instead.
2018-10-02 16:22:54 +02:00
Evgeny Vereshchagin
14f37112c8
icmp6-util: stop ignoring EAGAIN and EINTR in icmp6_receive
...
The code handling the errors was originally part of ndisc_recv, which,
being an event handler, would be simply turned off if it returned a negative
error code. It's no longer necessary. Plus, it helps avoid passing
an uninitialized value to radv_send.
Closes https://github.com/systemd/systemd/issues/10223 .
2018-10-02 12:58:07 +02:00
Thomas Haller
f21f31b24b
trivial: fix spelling in code comments
...
Based-on-patch-by: Rafael Fontenelle <rafaelff@gnome.org >
2018-09-30 21:32:33 +02:00
Yu Watanabe
213e759ad5
dhcp6: fix memleak about sd_event
2018-09-30 14:17:33 +02:00
Evgeny Vereshchagin
b387d3c132
dhcp6: fix an off-by-one error in dhcp6_option_parse_domainname
...
==14==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200055fa9c at pc 0x0000005458f1 bp 0x7ffc78940d90 sp 0x7ffc78940d88
READ of size 1 at 0x60200055fa9c thread T0
#0 0x5458f0 in dhcp6_option_parse_domainname /work/build/../../src/systemd/src/libsystemd-network/dhcp6-option.c:555:29
#1 0x54706e in dhcp6_lease_set_domains /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-lease.c:242:13
#2 0x53fce0 in client_parse_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:984:29
#3 0x53f3bc in client_receive_advertise /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1083:13
#4 0x53d57f in client_receive_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1182:21
#5 0x7f0f7159deee in source_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3042:21
#6 0x7f0f7159d431 in sd_event_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3455:21
#7 0x7f0f7159ea8d in sd_event_run /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3512:21
#8 0x531f2b in fuzz_client /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:44:9
#9 0x531bc1 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:53:9
#10 0x57bec8 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:570:15
#11 0x579d67 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:479:3
#12 0x57dc92 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:707:19
#13 0x580ca6 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:838:5
#14 0x55e968 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
#15 0x551a1c in main /src/libfuzzer/FuzzerMain.cpp:20:10
#16 0x7f0f701a082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#17 0x41e928 in _start (/out/fuzz-dhcp6-client+0x41e928)
2018-09-29 03:07:29 +00:00
Evgeny Vereshchagin
45a7becfea
tests: make fuzz-dhcp6-client work in containers provided by the OSS-Fuzz project
...
The containers come with an empty machine-id, which causes the fuzzer
to fail as soon as it starts.
See https://github.com/systemd/systemd/pull/9014#discussion_r189594104
2018-09-29 02:57:04 +00:00
Evgeny Vereshchagin
d89a400ed6
fuzz: add a fuzzer for dhcp6_client
2018-09-29 02:27:07 +00:00
Zbigniew Jędrzejewski-Szmek
83043e8dc8
Merge pull request #10190 from evverx/fuzz-ndisc-rs
...
Add a fuzzer for sd-ndisc and a reproducer for an infinite loop in ndisc_handle_datagram
2018-09-28 15:54:04 +02:00
Yu Watanabe
431a4bc8c0
dhcp6: fix memleak
...
Let's drop client_set_lease() because just writing what it does in both
places is simpler.
Fixes #10157 .
2018-09-27 18:14:19 +02:00
Yu Watanabe
cb1bdeaf56
dhcp6: fix buffer size checking
2018-09-27 23:48:51 +09:00
Yu Watanabe
23976cb928
dhcp6: use offsetof instead of sizeof
2018-09-27 23:41:23 +09:00