Blame SOURCES/0009-dhcp-internal-fixes-cve-2018-15688-rh1643984.patch

b4a831
From 0d4220fa98fbbd8aa0944a6ed87122b579716ff5 Mon Sep 17 00:00:00 2001
b4a831
From: Thomas Haller <thaller@redhat.com>
b4a831
Date: Mon, 10 Sep 2018 15:22:28 +0200
b4a831
Subject: [PATCH 1/9] systemd/dhcp: fix assertion starting DHCP client without
b4a831
 MAC address
b4a831
b4a831
An assertion in dhcp_network_bind_raw_socket() is triggered when
b4a831
starting an sd_dhcp_client without setting setting a MAC address
b4a831
first.
b4a831
b4a831
  - sd_dhcp_client_start()
b4a831
    - client_start()
b4a831
      - client_start_delayed()
b4a831
        - dhcp_network_bind_raw_socket()
b4a831
b4a831
In that case, the arp-type and MAC address is still unset. Note that
b4a831
dhcp_network_bind_raw_socket() already checks for a valid arp-type
b4a831
and MAC address below, so we should just gracefully return -EINVAL.
b4a831
b4a831
Maybe sd_dhcp_client_start() should fail earlier when starting without
b4a831
MAC address. But the failure here will be correctly propagated and
b4a831
the start aborted.
b4a831
b4a831
See-also: https://github.com/systemd/systemd/pull/10054
b4a831
(cherry picked from commit 34af574d5810ab2b0d6d354cbc28135cde4a55b1)
b4a831
(cherry picked from commit 0a797bdc2a592385a21e7ed918c08ef54a346d99)
b4a831
(cherry picked from commit f37ed84ca495ee212b1e82b9c5a5682c4acfebcd)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/dhcp-network.c | 2 --
b4a831
 1 file changed, 2 deletions(-)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/dhcp-network.c b/src/systemd/src/libsystemd-network/dhcp-network.c
b4a831
index 90fe29d04..80e9577cd 100644
b4a831
--- a/src/systemd/src/libsystemd-network/dhcp-network.c
b4a831
+++ b/src/systemd/src/libsystemd-network/dhcp-network.c
b4a831
@@ -128,8 +128,6 @@ int dhcp_network_bind_raw_socket(int ifindex, union sockaddr_union *link,
b4a831
         const uint8_t *bcast_addr = NULL;
b4a831
         uint8_t dhcp_hlen = 0;
b4a831
 
b4a831
-        assert_return(mac_addr_len > 0, -EINVAL);
b4a831
-
b4a831
         if (arp_type == ARPHRD_ETHER) {
b4a831
                 assert_return(mac_addr_len == ETH_ALEN, -EINVAL);
b4a831
                 memcpy(&eth_mac, mac_addr, ETH_ALEN);
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From ee92f8164c0ecee86cec104240f0bbe155901891 Mon Sep 17 00:00:00 2001
b4a831
From: Yu Watanabe <watanabe.yu+github@gmail.com>
b4a831
Date: Sun, 30 Sep 2018 20:23:58 +0900
b4a831
Subject: [PATCH 2/9] dhcp6: check option length before reading values
b4a831
b4a831
Fixes oss-fuzz#10746
b4a831
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10746.
b4a831
b4a831
https://github.com/systemd/systemd/pull/10213
b4a831
https://github.com/systemd/systemd/commit/84452783b8bcc44e0dbb7fa6ddc6dad8c064bdfe
b4a831
(cherry picked from commit 484e92e17f93aa9658944dc886d420ef32bc625e)
b4a831
(cherry picked from commit 0cec1cb93edd2efa6bee8e2ec1000d94a86ec61e)
b4a831
(cherry picked from commit 8b8b248679ee17b5c8e68fb8e8e6f6cd3ec32f03)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/dhcp6-internal.h  |  2 +-
b4a831
 src/systemd/src/libsystemd-network/dhcp6-option.c    | 11 ++++++-----
b4a831
 src/systemd/src/libsystemd-network/sd-dhcp6-client.c |  2 +-
b4a831
 3 files changed, 8 insertions(+), 7 deletions(-)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/dhcp6-internal.h b/src/systemd/src/libsystemd-network/dhcp6-internal.h
b4a831
index f1cbd6a4f..06e2e5324 100644
b4a831
--- a/src/systemd/src/libsystemd-network/dhcp6-internal.h
b4a831
+++ b/src/systemd/src/libsystemd-network/dhcp6-internal.h
b4a831
@@ -91,7 +91,7 @@ int dhcp6_option_append_pd(uint8_t *buf, size_t len, DHCP6IA *pd);
b4a831
 int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
b4a831
 int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
b4a831
                        size_t *optlen, uint8_t **optvalue);
b4a831
-int dhcp6_option_parse_status(DHCP6Option *option);
b4a831
+int dhcp6_option_parse_status(DHCP6Option *option, size_t len);
b4a831
 int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia);
b4a831
 int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
b4a831
                                 struct in6_addr **addrs, size_t count,
b4a831
diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
index a8a56463a..e462b7083 100644
b4a831
--- a/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
+++ b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
@@ -249,10 +249,11 @@ int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
b4a831
         return 0;
b4a831
 }
b4a831
 
b4a831
-int dhcp6_option_parse_status(DHCP6Option *option) {
b4a831
+int dhcp6_option_parse_status(DHCP6Option *option, size_t len) {
b4a831
         DHCP6StatusOption *statusopt = (DHCP6StatusOption *)option;
b4a831
 
b4a831
-        if (be16toh(option->len) + sizeof(DHCP6Option) < sizeof(*statusopt))
b4a831
+        if (len < sizeof(DHCP6StatusOption) ||
b4a831
+            be16toh(option->len) + sizeof(DHCP6Option) < sizeof(DHCP6StatusOption))
b4a831
                 return -ENOBUFS;
b4a831
 
b4a831
         return be16toh(statusopt->status);
b4a831
@@ -279,7 +280,7 @@ static int dhcp6_option_parse_address(DHCP6Option *option, DHCP6IA *ia,
b4a831
         }
b4a831
 
b4a831
         if (be16toh(option->len) + sizeof(DHCP6Option) > sizeof(*addr_option)) {
b4a831
-                r = dhcp6_option_parse_status((DHCP6Option *)addr_option->options);
b4a831
+                r = dhcp6_option_parse_status((DHCP6Option *)addr_option->options, be16toh(option->len) + sizeof(DHCP6Option) - sizeof(*addr_option));
b4a831
                 if (r != 0)
b4a831
                         return r < 0 ? r: 0;
b4a831
         }
b4a831
@@ -319,7 +320,7 @@ static int dhcp6_option_parse_pdprefix(DHCP6Option *option, DHCP6IA *ia,
b4a831
         }
b4a831
 
b4a831
         if (be16toh(option->len) + sizeof(DHCP6Option) > sizeof(*pdprefix_option)) {
b4a831
-                r = dhcp6_option_parse_status((DHCP6Option *)pdprefix_option->options);
b4a831
+                r = dhcp6_option_parse_status((DHCP6Option *)pdprefix_option->options, be16toh(option->len) + sizeof(DHCP6Option) - sizeof(*pdprefix_option));
b4a831
                 if (r != 0)
b4a831
                         return r < 0 ? r: 0;
b4a831
         }
b4a831
@@ -464,7 +465,7 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
b4a831
 
b4a831
                 case SD_DHCP6_OPTION_STATUS_CODE:
b4a831
 
b4a831
-                        status = dhcp6_option_parse_status(option);
b4a831
+                        status = dhcp6_option_parse_status(option, optlen);
b4a831
                         if (status) {
b4a831
                                 log_dhcp6_client(client, "IA status %d",
b4a831
                                                  status);
b4a831
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
index ca03f580e..b82e3f45f 100644
b4a831
--- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
+++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
@@ -828,7 +828,7 @@ static int client_parse_message(
b4a831
                         break;
b4a831
 
b4a831
                 case SD_DHCP6_OPTION_STATUS_CODE:
b4a831
-                        status = dhcp6_option_parse_status(option);
b4a831
+                        status = dhcp6_option_parse_status(option, optlen);
b4a831
                         if (status) {
b4a831
                                 log_dhcp6_client(client, "%s Status %s",
b4a831
                                                  dhcp6_message_type_to_string(message->type),
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From a944785f244e92094eb4379cf12e76f5205037d3 Mon Sep 17 00:00:00 2001
b4a831
From: Evgeny Vereshchagin <evvers@ya.ru>
b4a831
Date: Sat, 29 Sep 2018 03:06:10 +0000
b4a831
Subject: [PATCH 3/9] dhcp6: fix an off-by-one error in
b4a831
 dhcp6_option_parse_domainname
b4a831
b4a831
==14==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200055fa9c at pc 0x0000005458f1 bp 0x7ffc78940d90 sp 0x7ffc78940d88
b4a831
READ of size 1 at 0x60200055fa9c thread T0
b4a831
    #0 0x5458f0 in dhcp6_option_parse_domainname /work/build/../../src/systemd/src/libsystemd-network/dhcp6-option.c:555:29
b4a831
    #1 0x54706e in dhcp6_lease_set_domains /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-lease.c:242:13
b4a831
    #2 0x53fce0 in client_parse_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:984:29
b4a831
    #3 0x53f3bc in client_receive_advertise /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1083:13
b4a831
    #4 0x53d57f in client_receive_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1182:21
b4a831
    #5 0x7f0f7159deee in source_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3042:21
b4a831
    #6 0x7f0f7159d431 in sd_event_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3455:21
b4a831
    #7 0x7f0f7159ea8d in sd_event_run /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3512:21
b4a831
    #8 0x531f2b in fuzz_client /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:44:9
b4a831
    #9 0x531bc1 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:53:9
b4a831
    #10 0x57bec8 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:570:15
b4a831
    #11 0x579d67 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:479:3
b4a831
    #12 0x57dc92 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:707:19
b4a831
    #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
b4a831
    #14 0x55e968 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
b4a831
    #15 0x551a1c in main /src/libfuzzer/FuzzerMain.cpp:20:10
b4a831
    #16 0x7f0f701a082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
b4a831
    #17 0x41e928 in _start (/out/fuzz-dhcp6-client+0x41e928)
b4a831
b4a831
https://github.com/systemd/systemd/pull/10200
b4a831
https://github.com/systemd/systemd/commit/b387d3c1327a3ad2a2509bd3d3491e674392ff21
b4a831
(cherry picked from commit 7cb7cffc4962245a32e87017bcf264005c043250)
b4a831
(cherry picked from commit cd3aacefdd0b91741b7b2e7b5ee5baab210addd9)
b4a831
(cherry picked from commit 5b140a77bc7b01dc002dbf28a7a2507a27a63d7c)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/dhcp6-option.c | 2 +-
b4a831
 1 file changed, 1 insertion(+), 1 deletion(-)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
index e462b7083..ff1cbf13d 100644
b4a831
--- a/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
+++ b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
@@ -566,7 +566,7 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
b4a831
                                 /* Literal label */
b4a831
                                 label = (const char *)&optval[pos];
b4a831
                                 pos += c;
b4a831
-                                if (pos > optlen)
b4a831
+                                if (pos >= optlen)
b4a831
                                         return -EMSGSIZE;
b4a831
 
b4a831
                                 if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX)) {
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From fc04015063d44a61b85bdf2c2648d9ac9fb4a446 Mon Sep 17 00:00:00 2001
b4a831
From: Yu Watanabe <watanabe.yu+github@gmail.com>
b4a831
Date: Thu, 27 Sep 2018 18:04:59 +0900
b4a831
Subject: [PATCH 4/9] sd-dhcp-lease: fix memleaks
b4a831
b4a831
(cherry picked from commit e2975f854831d08a25b4f5eb329b6d04102e115f)
b4a831
(cherry picked from commit 157094abd83f933fad142758a7d177cfa1a347f7)
b4a831
(cherry picked from commit 3fd9d11619a5e60d375076fbe13851dd1d3a4a63)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/sd-dhcp-lease.c | 2 ++
b4a831
 1 file changed, 2 insertions(+)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp-lease.c b/src/systemd/src/libsystemd-network/sd-dhcp-lease.c
b4a831
index 33a0796a8..841d07926 100644
b4a831
--- a/src/systemd/src/libsystemd-network/sd-dhcp-lease.c
b4a831
+++ b/src/systemd/src/libsystemd-network/sd-dhcp-lease.c
b4a831
@@ -279,6 +279,8 @@ sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease) {
b4a831
                 free(option);
b4a831
         }
b4a831
 
b4a831
+        free(lease->root_path);
b4a831
+        free(lease->timezone);
b4a831
         free(lease->hostname);
b4a831
         free(lease->domainname);
b4a831
         free(lease->dns);
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From ae56f71f5bd4233f335ec4c2a5172b59be3d80ca Mon Sep 17 00:00:00 2001
b4a831
From: Yu Watanabe <watanabe.yu+github@gmail.com>
b4a831
Date: Thu, 27 Sep 2018 23:48:51 +0900
b4a831
Subject: [PATCH 5/9] dhcp6: fix buffer size checking
b4a831
b4a831
(cherry picked from commit cb1bdeaf56852275e6b0dd1fba932bb174767f70)
b4a831
(cherry picked from commit 91fb1673d5217aaf1461998fd2675630f5c265f9)
b4a831
(cherry picked from commit 15a3c6c692ee0125d4673df42ef8986e9e3d69c7)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/sd-dhcp6-client.c | 4 ++--
b4a831
 1 file changed, 2 insertions(+), 2 deletions(-)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
index b82e3f45f..b65c31171 100644
b4a831
--- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
+++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
@@ -776,8 +776,8 @@ static int client_parse_message(
b4a831
                 uint8_t *optval;
b4a831
                 be32_t iaid_lease;
b4a831
 
b4a831
-                if (len < offsetof(DHCP6Option, data) ||
b4a831
-                    len < offsetof(DHCP6Option, data) + be16toh(option->len))
b4a831
+                if (len < pos + offsetof(DHCP6Option, data) ||
b4a831
+                    len < pos + offsetof(DHCP6Option, data) + be16toh(option->len))
b4a831
                         return -ENOBUFS;
b4a831
 
b4a831
                 optcode = be16toh(option->code);
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From 9babde953073b460d8bcda13329c60a0a74cdc3c Mon Sep 17 00:00:00 2001
b4a831
From: Yu Watanabe <watanabe.yu+github@gmail.com>
b4a831
Date: Fri, 19 Oct 2018 03:44:56 +0900
b4a831
Subject: [PATCH 6/9] sd-dhcp6: fix argument and error handling of
b4a831
 dhcp6_option_parse_status()
b4a831
b4a831
(cherry picked from commit 91c43f3978fa7c8341550b9ca279e460ba7e74e6)
b4a831
(cherry picked from commit 373cbfc8c6e9591b3c8cc12d58c4b31ac35ab24f)
b4a831
(cherry picked from commit 0e93fd895daa6f0f578ffa8fc4ed3e0ea85c62e8)
b4a831
(cherry picked from commit 6ea13fc82523bebaa08cf2ab8404e751a654261f)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/dhcp6-option.c    | 10 ++++++----
b4a831
 src/systemd/src/libsystemd-network/sd-dhcp6-client.c |  9 +++++----
b4a831
 2 files changed, 11 insertions(+), 8 deletions(-)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
index ff1cbf13d..cfddefcb5 100644
b4a831
--- a/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
+++ b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
@@ -465,13 +465,15 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
b4a831
 
b4a831
                 case SD_DHCP6_OPTION_STATUS_CODE:
b4a831
 
b4a831
-                        status = dhcp6_option_parse_status(option, optlen);
b4a831
-                        if (status) {
b4a831
+                        status = dhcp6_option_parse_status(option, optlen + sizeof(DHCP6Option));
b4a831
+                        if (status < 0) {
b4a831
+                                r = status;
b4a831
+                                goto error;
b4a831
+                        }
b4a831
+                        if (status > 0) {
b4a831
                                 log_dhcp6_client(client, "IA status %d",
b4a831
                                                  status);
b4a831
 
b4a831
-                                dhcp6_lease_free_ia(ia);
b4a831
-
b4a831
                                 r = -EINVAL;
b4a831
                                 goto error;
b4a831
                         }
b4a831
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
index b65c31171..15c4f445f 100644
b4a831
--- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
+++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
b4a831
@@ -828,13 +828,14 @@ static int client_parse_message(
b4a831
                         break;
b4a831
 
b4a831
                 case SD_DHCP6_OPTION_STATUS_CODE:
b4a831
-                        status = dhcp6_option_parse_status(option, optlen);
b4a831
-                        if (status) {
b4a831
+                        status = dhcp6_option_parse_status(option, optlen + sizeof(DHCP6Option));
b4a831
+                        if (status < 0)
b4a831
+                                return status;
b4a831
+
b4a831
+                        if (status > 0) {
b4a831
                                 log_dhcp6_client(client, "%s Status %s",
b4a831
                                                  dhcp6_message_type_to_string(message->type),
b4a831
                                                  dhcp6_message_status_to_string(status));
b4a831
-                                dhcp6_lease_free_ia(&lease->ia);
b4a831
-                                dhcp6_lease_free_ia(&lease->pd);
b4a831
 
b4a831
                                 return -EINVAL;
b4a831
                         }
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From 19b82104da425efdb9ad0207ccabf5a1a091b81a Mon Sep 17 00:00:00 2001
b4a831
From: Yu Watanabe <watanabe.yu+github@gmail.com>
b4a831
Date: Fri, 19 Oct 2018 03:42:10 +0900
b4a831
Subject: [PATCH 7/9] sd-dhcp6: make dhcp6_option_parse_domainname() not store
b4a831
 empty domain
b4a831
b4a831
This improves performance of fuzzer.
b4a831
C.f. oss-fuzz#11019.
b4a831
b4a831
(cherry picked from commit 3c72b6ed4252e7ff5f7704bfe44557ec197b47fa)
b4a831
(cherry picked from commit 50403cccee28c7dcd54b138a0d3b3f69ea0204fe)
b4a831
(cherry picked from commit f11f5abb1a8b96b553d2d156f8b5cf440695c04d)
b4a831
(cherry picked from commit c836279fca80fb22ca7ef02acaa5b987fee61123)
b4a831
---
b4a831
 .../src/libsystemd-network/dhcp6-option.c     | 66 ++++++++-----------
b4a831
 1 file changed, 29 insertions(+), 37 deletions(-)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
index cfddefcb5..be5c22237 100644
b4a831
--- a/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
+++ b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
@@ -555,6 +555,7 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
b4a831
                 bool first = true;
b4a831
 
b4a831
                 for (;;) {
b4a831
+                        const char *label;
b4a831
                         uint8_t c;
b4a831
 
b4a831
                         c = optval[pos++];
b4a831
@@ -562,47 +563,41 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
b4a831
                         if (c == 0)
b4a831
                                 /* End of name */
b4a831
                                 break;
b4a831
-                        else if (c <= 63) {
b4a831
-                                const char *label;
b4a831
-
b4a831
-                                /* Literal label */
b4a831
-                                label = (const char *)&optval[pos];
b4a831
-                                pos += c;
b4a831
-                                if (pos >= optlen)
b4a831
-                                        return -EMSGSIZE;
b4a831
-
b4a831
-                                if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX)) {
b4a831
-                                        r = -ENOMEM;
b4a831
-                                        goto fail;
b4a831
-                                }
b4a831
-
b4a831
-                                if (first)
b4a831
-                                        first = false;
b4a831
-                                else
b4a831
-                                        ret[n++] = '.';
b4a831
-
b4a831
-                                r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX);
b4a831
-                                if (r < 0)
b4a831
-                                        goto fail;
b4a831
-
b4a831
-                                n += r;
b4a831
-                                continue;
b4a831
-                        } else {
b4a831
-                                r = -EBADMSG;
b4a831
-                                goto fail;
b4a831
-                        }
b4a831
-                }
b4a831
+                        if (c > 63)
b4a831
+                                return -EBADMSG;
b4a831
+
b4a831
+                        /* Literal label */
b4a831
+                        label = (const char *)&optval[pos];
b4a831
+                        pos += c;
b4a831
+                        if (pos >= optlen)
b4a831
+                                return -EMSGSIZE;
b4a831
+
b4a831
+                        if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX))
b4a831
+                                return -ENOMEM;
b4a831
+
b4a831
+                        if (first)
b4a831
+                                first = false;
b4a831
+                        else
b4a831
+                                ret[n++] = '.';
b4a831
+
b4a831
+                        r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX);
b4a831
+                        if (r < 0)
b4a831
+                                return r;
b4a831
 
b4a831
-                if (!GREEDY_REALLOC(ret, allocated, n + 1)) {
b4a831
-                        r = -ENOMEM;
b4a831
-                        goto fail;
b4a831
+                        n += r;
b4a831
                 }
b4a831
 
b4a831
+                if (n == 0)
b4a831
+                        continue;
b4a831
+
b4a831
+                if (!GREEDY_REALLOC(ret, allocated, n + 1))
b4a831
+                        return -ENOMEM;
b4a831
+
b4a831
                 ret[n] = 0;
b4a831
 
b4a831
                 r = strv_extend(&names, ret);
b4a831
                 if (r < 0)
b4a831
-                        goto fail;
b4a831
+                        return r;
b4a831
 
b4a831
                 idx++;
b4a831
         }
b4a831
@@ -610,7 +605,4 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
b4a831
         *str_arr = TAKE_PTR(names);
b4a831
 
b4a831
         return idx;
b4a831
-
b4a831
-fail:
b4a831
-        return r;
b4a831
 }
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From 7dd0b1ae8cc44a6e3c91dc921a278f939d045f0d Mon Sep 17 00:00:00 2001
b4a831
From: Li Song <song.li@honeywell.com>
b4a831
Date: Fri, 19 Oct 2018 13:41:51 -0400
b4a831
Subject: [PATCH 8/9] sd-dhcp: remove unreachable route after rebinding return
b4a831
 NAK
b4a831
b4a831
(cherry picked from commit cc3981b1272b9ce37e7d734a7b2f42e84acac535)
b4a831
(cherry picked from commit 915c2f675a23b2ae16d292d1ac570706f76b384d)
b4a831
(cherry picked from commit cb77290a696dce924e2a993690634986ac035490)
b4a831
(cherry picked from commit f211b140a5861ddedc2424946e3ab07d3b642b5f)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/sd-dhcp-client.c | 2 ++
b4a831
 1 file changed, 2 insertions(+)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp-client.c b/src/systemd/src/libsystemd-network/sd-dhcp-client.c
b4a831
index c2f81e1c4..c28025410 100644
b4a831
--- a/src/systemd/src/libsystemd-network/sd-dhcp-client.c
b4a831
+++ b/src/systemd/src/libsystemd-network/sd-dhcp-client.c
b4a831
@@ -1649,6 +1649,8 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i
b4a831
                         client->timeout_resend =
b4a831
                                 sd_event_source_unref(client->timeout_resend);
b4a831
 
b4a831
+                        client_notify(client, SD_DHCP_CLIENT_EVENT_EXPIRED);
b4a831
+
b4a831
                         r = client_initialize(client);
b4a831
                         if (r < 0)
b4a831
                                 goto error;
b4a831
-- 
b4a831
2.17.1
b4a831
b4a831
b4a831
From 5a89e393279e8d0c8c2943b4cce99b91c5ebe903 Mon Sep 17 00:00:00 2001
b4a831
From: Lennart Poettering <lennart@poettering.net>
b4a831
Date: Fri, 19 Oct 2018 12:12:33 +0200
b4a831
Subject: [PATCH 9/9] dhcp6: make sure we have enough space for the DHCP6
b4a831
 option header
b4a831
b4a831
Fixes a vulnerability originally discovered by Felix Wilhelm from
b4a831
Google.
b4a831
b4a831
CVE-2018-15688
b4a831
LP: #1795921
b4a831
https://bugzilla.redhat.com/show_bug.cgi?id=1639067
b4a831
b4a831
(cherry picked from commit 4dac5eaba4e419b29c97da38a8b1f82336c2c892)
b4a831
(cherry picked from commit 01ca2053bbea09f35b958c8cc7631e15469acb79)
b4a831
(cherry picked from commit fc230dca139142f409d7bac99dbfabe9b004e2fb)
b4a831
(cherry picked from commit cc1e5a7f5731f223d1eb8473fa0eecbedfc0ae5f)
b4a831
---
b4a831
 src/systemd/src/libsystemd-network/dhcp6-option.c | 2 +-
b4a831
 1 file changed, 1 insertion(+), 1 deletion(-)
b4a831
b4a831
diff --git a/src/systemd/src/libsystemd-network/dhcp6-option.c b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
index be5c22237..22970443d 100644
b4a831
--- a/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
+++ b/src/systemd/src/libsystemd-network/dhcp6-option.c
b4a831
@@ -105,7 +105,7 @@ int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, DHCP6IA *ia) {
b4a831
                 return -EINVAL;
b4a831
         }
b4a831
 
b4a831
-        if (*buflen < len)
b4a831
+        if (*buflen < offsetof(DHCP6Option, data) + len)
b4a831
                 return -ENOBUFS;
b4a831
 
b4a831
         ia_hdr = *buf;
b4a831
-- 
b4a831
2.17.1
b4a831