Commit Graph

869 Commits

Author SHA1 Message Date
Thomas Haller 0e408b82b8 dhcp6-client: handle IAID with value zero
config_parse_iaid(), dhcp_identifier_set_iaid() and sd_dhcp6_client_set_iaid() all
allow for the IAID to be zero. Also, RFC 3315 makes no mention that zero
would be invalid.

However, client_ensure_iaid() would take an IAID of zero as a sign that
the values was unset. Fix that by keeping track whether IAID is
initialized.
2018-11-23 17:09:29 +01:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Yu Watanabe ff4b032106 sd-ndisc: do not unref() event sources when update or disable them 2018-11-16 22:57:42 +09:00
Yu Watanabe 144faa8ea5 sd-ndisc: use structured initializer at one more place 2018-11-16 22:57:42 +09:00
Yu Watanabe 807a8edeb1 sd-radv: do not unref() event sources when update or disable them 2018-11-16 22:57:42 +09:00
Yu Watanabe 78f9d24f7b sd-radv: use structured initializer at one more place 2018-11-16 22:57:42 +09:00
Yu Watanabe 6ec11d46dc lldp: do not unref() event sources when update or disable them 2018-11-16 22:57:42 +09:00
Yu Watanabe 8158b90d59 lldp: use structured initializer at one more place 2018-11-16 22:57:42 +09:00
Yu Watanabe 32ab66c5ee ipv4acd: do not unref() event sources when update or disable them 2018-11-16 22:57:42 +09:00
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:

6d5e65f645 (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