connman: fix CVE-2021-26675, CVE-2021-26676
PATCH 1/1 connman: fix CVE-2021-26675, CVE-2021-26676
From: Catalin Enache <[email protected]>
A stack-based buffer overflow in dnsproxy in ConnMan before 1.39 could be used by network adjacent attackers to execute code.
gdhcp in ConnMan before 1.39 could be used by network-adjacent. attackers to leak sensitive stack information, allowing further exploitation of bugs in gdhcp.
References:
https://nvd.nist.gov/vuln/detail/CVE-2021-26675
https://nvd.nist.gov/vuln/detail/CVE-2021-26676
Upstream patches:
https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=e4079a20f617a4b076af503f6e4e8b0304c9f2cb
https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=58d397ba74873384aee449690a9070bacd5676fa
https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=a74524b3e3fad81b0fd1084ffdf9f2ea469cd9b1
--- .../connman/connman/CVE-2021-26675.patch | 62 +++++ .../connman/connman/CVE-2021-26676-0001.patch | 231 ++++++++++++++++++ .../connman/connman/CVE-2021-26676-0002.patch | 33 +++ .../connman/connman_1.37.bb | 3 + 4 files changed, 329 insertions(+) create mode 100644 meta/recipes-connectivity/connman/connman/CVE-2021-26675.patch create mode 100644 meta/recipes-connectivity/connman/connman/CVE-2021-26676-0001.patch create mode 100644 meta/recipes-connectivity/connman/connman/CVE-2021-26676-0002.patch
meta/recipes-connectivity/connman/connman/CVE-2021-26675.patch new file +62 -0
@@ -0,0 +1,62 @@ +From e4079a20f617a4b076af503f6e4e8b0304c9f2cb Mon Sep 17 00:00:00 2001 +From: Colin Wee <[email protected]> +Date: Thu, 28 Jan 2021 19:41:53 +0100 +Subject: [PATCH] dnsproxy: Add length checks to prevent buffer overflow + +Fixes: CVE-2021-26675 + +Upstream-Status: Backport +CVE: CVE-2021-26675 + +Reference to upstream patch: +https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=e4079a20f617a4b076af503f6e4e8b0304c9f2cb + +Signed-off-by: Catalin Enache <[email protected]> +--- + src/dnsproxy.c | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/src/dnsproxy.c b/src/dnsproxy.c +index a7bf87a1..4f5c897f 100644 +--- a/src/dnsproxy.c ++++ b/src/dnsproxy.c +@@ -1767,6 +1767,7 @@ static char *uncompress(int16_t field_count, char *start, char *end, + char **uncompressed_ptr) + { + char *uptr = *uncompressed_ptr; /* position in result buffer */ ++ char * const uncomp_end = uncompressed + uncomp_len - 1; + + debug("count %d ptr %p end %p uptr %p", field_count, ptr, end, uptr); + +@@ -1787,12 +1788,15 @@ static char *uncompress(int16_t field_count, char *start, char *end, + * tmp buffer. + */ + +- ulen = strlen(name); +- strncpy(uptr, name, uncomp_len - (uptr - uncompressed)); +- + debug("pos %d ulen %d left %d name %s", pos, ulen, + (int)(uncomp_len - (uptr - uncompressed)), uptr); + ++ ulen = strlen(name); ++ if ((uptr + ulen + 1) > uncomp_end) { ++ goto out; ++ } ++ strncpy(uptr, name, uncomp_len - (uptr - uncompressed)); ++ + uptr += ulen; + *uptr++ = '\0'; + +@@ -1802,6 +1806,10 @@ static char *uncompress(int16_t field_count, char *start, char *end, + * We copy also the fixed portion of the result (type, class, + * ttl, address length and the address) + */ ++ if ((uptr + NS_RRFIXEDSZ) > uncomp_end) { ++ debug("uncompressed data too large for buffer"); ++ goto out; ++ } + memcpy(uptr, ptr, NS_RRFIXEDSZ); + + dns_type = uptr[0] << 8 | uptr[1]; +-- +2.17.1
meta/recipes-connectivity/connman/connman/CVE-2021-26676-0001.patch new file +231 -0
231 lines not on this page · raw message
meta/recipes-connectivity/connman/connman/CVE-2021-26676-0002.patch new file +33 -0
@@ -0,0 +1,33 @@ +From a74524b3e3fad81b0fd1084ffdf9f2ea469cd9b1 Mon Sep 17 00:00:00 2001 +From: Colin Wee <[email protected]> +Date: Thu, 28 Jan 2021 19:41:09 +0100 +Subject: [PATCH] gdhcp: Avoid leaking stack data via unitiialized variable + +Fixes: CVE-2021-26676 + +Upstream-Status: Backport +CVE: CVE-2021-26676 + +Reference to upstream patch: +https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=a74524b3e3fad81b0fd1084ffdf9f2ea469cd9b1 + +Signed-off-by: Catalin Enache <[email protected]> +--- + gdhcp/client.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdhcp/client.c b/gdhcp/client.c +index 6a5613e7..c7b85e58 100644 +--- a/gdhcp/client.c ++++ b/gdhcp/client.c +@@ -2270,7 +2270,7 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, + { + GDHCPClient *dhcp_client = user_data; + struct sockaddr_in dst_addr = { 0 }; +- struct dhcp_packet packet; ++ struct dhcp_packet packet = { 0 }; + struct dhcpv6_packet *packet6 = NULL; + uint8_t *message_type = NULL, *client_id = NULL, *option, + *server_id = NULL; +-- +2.17.1
meta/recipes-connectivity/connman/connman_1.37.bb +3 -0
@@ -6,6 +6,9 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \ file://0001-gweb-fix-segfault-with-musl-v1.1.21.patch \ file://connman \ file://no-version-scripts.patch \ + file://CVE-2021-26675.patch \ + file://CVE-2021-26676-0001.patch \ + file://CVE-2021-26676-0002.patch \ " SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch"
Signature · 1 line
2.27.0