diff -Nru bluez-5.48/debian/changelog bluez-5.48/debian/changelog --- bluez-5.48/debian/changelog 2022-02-03 23:25:37.000000000 +0000 +++ bluez-5.48/debian/changelog 2022-06-08 11:19:20.000000000 +0000 @@ -1,3 +1,17 @@ +bluez (5.48-0ubuntu3.9) bionic-security; urgency=medium + + * SECURITY UPDATE: various security improvements (LP: #1977968) + - debian/patches/avdtp-security.patch: check if capabilities are valid + before attempting to copy them in profiles/audio/avdtp.c. + - debian/patches/avdtp-security-2.patch: fix size comparison and + variable misassignment in profiles/audio/avdtp.c. + - debian/patches/avrcp-security.patch: make sure the number of bytes in + the params_len matches the remaining bytes received so the code don't + end up accessing invalid memory in profiles/audio/avrcp.c. + - No CVE numbers + + -- Marc Deslauriers Wed, 08 Jun 2022 07:19:20 -0400 + bluez (5.48-0ubuntu3.8) bionic-security; urgency=medium * SECURITY UPDATE: Integer overflow in gatt server protocol could lead to diff -Nru bluez-5.48/debian/patches/avdtp-security-2.patch bluez-5.48/debian/patches/avdtp-security-2.patch --- bluez-5.48/debian/patches/avdtp-security-2.patch 1970-01-01 00:00:00.000000000 +0000 +++ bluez-5.48/debian/patches/avdtp-security-2.patch 2022-06-08 11:17:30.000000000 +0000 @@ -0,0 +1,35 @@ +From 0388794dc5fdb73a4ea88bcf148de0a12b4364d4 Mon Sep 17 00:00:00 2001 +From: Archie Pusaka +Date: Thu, 17 Jun 2021 08:53:34 +0800 +Subject: avdtp: Fix parsing capabilities + +This patch fixes size comparison and variable misassignment. + +Reviewed-by: Alain Michaud +Reviewed-by: Michael Sun +--- + profiles/audio/avdtp.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +(limited to 'profiles/audio/avdtp.c') + +--- a/profiles/audio/avdtp.c ++++ b/profiles/audio/avdtp.c +@@ -1268,7 +1268,7 @@ static GSList *caps_to_list(uint8_t *dat + + cap = (struct avdtp_service_capability *)data; + +- if (sizeof(*cap) + cap->length >= size) { ++ if (sizeof(*cap) + cap->length > size) { + error("Invalid capability data in getcap resp"); + break; + } +@@ -1290,7 +1290,7 @@ static GSList *caps_to_list(uint8_t *dat + switch (cap->category) { + case AVDTP_MEDIA_CODEC: + if (codec) +- *codec = cap; ++ *codec = cpy; + break; + case AVDTP_DELAY_REPORTING: + if (delay_reporting) diff -Nru bluez-5.48/debian/patches/avdtp-security.patch bluez-5.48/debian/patches/avdtp-security.patch --- bluez-5.48/debian/patches/avdtp-security.patch 1970-01-01 00:00:00.000000000 +0000 +++ bluez-5.48/debian/patches/avdtp-security.patch 2022-06-08 11:17:24.000000000 +0000 @@ -0,0 +1,102 @@ +From 7a80d2096f1b7125085e21448112aa02f49f5e9a Mon Sep 17 00:00:00 2001 +From: Luiz Augusto von Dentz +Date: Thu, 29 Apr 2021 17:10:50 -0700 +Subject: avdtp: Fix accepting invalid/malformed capabilities + +Check if capabilities are valid before attempting to copy them. +--- + profiles/audio/avdtp.c | 56 ++++++++++++++++++++++++++++++++------------------ + 1 file changed, 36 insertions(+), 20 deletions(-) + +--- a/profiles/audio/avdtp.c ++++ b/profiles/audio/avdtp.c +@@ -1250,43 +1250,53 @@ struct avdtp_remote_sep *avdtp_find_remo + return NULL; + } + +-static GSList *caps_to_list(uint8_t *data, int size, ++static GSList *caps_to_list(uint8_t *data, size_t size, + struct avdtp_service_capability **codec, + gboolean *delay_reporting) + { ++ struct avdtp_service_capability *cap; + GSList *caps; +- int processed; + + if (delay_reporting) + *delay_reporting = FALSE; + +- for (processed = 0, caps = NULL; processed + 2 <= size;) { +- struct avdtp_service_capability *cap; +- uint8_t length, category; ++ if (size < sizeof(*cap)) ++ return NULL; + +- category = data[0]; +- length = data[1]; ++ for (caps = NULL; size >= sizeof(*cap);) { ++ struct avdtp_service_capability *cpy; + +- if (processed + 2 + length > size) { ++ cap = (struct avdtp_service_capability *)data; ++ ++ if (sizeof(*cap) + cap->length >= size) { + error("Invalid capability data in getcap resp"); + break; + } + +- cap = g_malloc(sizeof(struct avdtp_service_capability) + +- length); +- memcpy(cap, data, 2 + length); +- +- processed += 2 + length; +- data += 2 + length; +- +- caps = g_slist_append(caps, cap); +- +- if (category == AVDTP_MEDIA_CODEC && +- length >= +- sizeof(struct avdtp_media_codec_capability)) +- *codec = cap; +- else if (category == AVDTP_DELAY_REPORTING && delay_reporting) +- *delay_reporting = TRUE; ++ if (cap->category == AVDTP_MEDIA_CODEC && ++ cap->length < sizeof(**codec)) { ++ error("Invalid codec data in getcap resp"); ++ break; ++ } ++ ++ cpy = btd_malloc(sizeof(*cpy) + cap->length); ++ memcpy(cpy, cap, sizeof(*cap) + cap->length); ++ ++ size -= sizeof(*cap) + cap->length; ++ data += sizeof(*cap) + cap->length; ++ ++ caps = g_slist_append(caps, cpy); ++ ++ switch (cap->category) { ++ case AVDTP_MEDIA_CODEC: ++ if (codec) ++ *codec = cap; ++ break; ++ case AVDTP_DELAY_REPORTING: ++ if (delay_reporting) ++ *delay_reporting = TRUE; ++ break; ++ } + } + + return caps; +@@ -1483,6 +1493,12 @@ static gboolean avdtp_setconf_cmd(struct + &stream->codec, + &stream->delay_reporting); + ++ if (!stream->caps || !stream->codec) { ++ err = AVDTP_UNSUPPORTED_CONFIGURATION; ++ category = 0x00; ++ goto failed_stream; ++ } ++ + /* Verify that the Media Transport capability's length = 0. Reject otherwise */ + for (l = stream->caps; l != NULL; l = g_slist_next(l)) { + struct avdtp_service_capability *cap = l->data; diff -Nru bluez-5.48/debian/patches/avrcp-security.patch bluez-5.48/debian/patches/avrcp-security.patch --- bluez-5.48/debian/patches/avrcp-security.patch 1970-01-01 00:00:00.000000000 +0000 +++ bluez-5.48/debian/patches/avrcp-security.patch 2022-06-08 11:17:40.000000000 +0000 @@ -0,0 +1,29 @@ +From e2b0f0d8d63e1223bb714a9efb37e2257818268b Mon Sep 17 00:00:00 2001 +From: Luiz Augusto von Dentz +Date: Thu, 29 Apr 2021 18:18:57 -0700 +Subject: avrcp: Fix not checking if params_len match number of received bytes + +This makes sure the number of bytes in the params_len matches the +remaining bytes received so the code don't end up accessing invalid +memory. +--- + profiles/audio/avrcp.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/profiles/audio/avrcp.c ++++ b/profiles/audio/avrcp.c +@@ -1844,6 +1844,14 @@ static size_t handle_vendordep_pdu(struc + goto err_metadata; + } + ++ operands += sizeof(*pdu); ++ operand_count -= sizeof(*pdu); ++ ++ if (pdu->params_len != operand_count) { ++ DBG("AVRCP PDU parameters length don't match"); ++ pdu->params_len = operand_count; ++ } ++ + for (handler = session->control_handlers; handler->pdu_id; handler++) { + if (handler->pdu_id == pdu->pdu_id) + break; diff -Nru bluez-5.48/debian/patches/series bluez-5.48/debian/patches/series --- bluez-5.48/debian/patches/series 2022-02-03 22:43:59.000000000 +0000 +++ bluez-5.48/debian/patches/series 2022-06-08 11:17:34.000000000 +0000 @@ -29,3 +29,6 @@ CVE-2021-43400.patch CVE-2019-8922.patch CVE-2022-0204.patch +avdtp-security.patch +avdtp-security-2.patch +avrcp-security.patch