]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
bluez5: fix CVE-2022-0204
authorRalph Siemsen <ralph.siemsen@linaro.org>
Fri, 1 Apr 2022 01:13:33 +0000 (21:13 -0400)
committerSteve Sakoman <steve@sakoman.com>
Mon, 4 Apr 2022 14:22:32 +0000 (04:22 -1000)
Fix heap overflow when appending prepare writes

The code shall check if the prepare writes would append more the
allowed maximum attribute length.

Upstream-Status: Backport [https://github.com/bluez/bluez/commit/591c546c536b42bef696d027f64aa22434f8c3f0]
CVE: CVE-2022-0204

Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/recipes-connectivity/bluez5/bluez5.inc
meta/recipes-connectivity/bluez5/bluez5/CVE-2022-0204.patch [new file with mode: 0644]

index 7cf061dcf620b4a02aa69b3fb70230c39629898b..4d4348898a0f721edf04ddf20a7e2dc3cc63d1a9 100644 (file)
@@ -55,6 +55,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
            file://CVE-2021-0129.patch \
            file://CVE-2021-3588.patch \
           file://CVE-2021-3658.patch \
+           file://CVE-2022-0204.patch \
            "
 S = "${WORKDIR}/bluez-${PV}"
 
diff --git a/meta/recipes-connectivity/bluez5/bluez5/CVE-2022-0204.patch b/meta/recipes-connectivity/bluez5/bluez5/CVE-2022-0204.patch
new file mode 100644 (file)
index 0000000..646b5dd
--- /dev/null
@@ -0,0 +1,66 @@
+From 0d328fdf6564b67fc2ec3533e3da201ebabcc9e3 Mon Sep 17 00:00:00 2001
+From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
+Date: Tue, 8 Jun 2021 16:46:49 -0700
+Subject: [PATCH] shared/gatt-server: Fix heap overflow when appending prepare
+ writes
+
+The code shall check if the prepare writes would append more the
+allowed maximum attribute length.
+
+Fixes https://github.com/bluez/bluez/security/advisories/GHSA-479m-xcq5-9g2q
+
+Upstream-Status: Backport [https://github.com/bluez/bluez/commit/591c546c536b42bef696d027f64aa22434f8c3f0]
+Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
+CVE: CVE-2022-0204
+
+---
+ src/shared/gatt-server.c | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
+index 0c25a97..20e14bc 100644
+--- a/src/shared/gatt-server.c
++++ b/src/shared/gatt-server.c
+@@ -816,6 +816,20 @@ static uint8_t authorize_req(struct bt_gatt_server *server,
+                                               server->authorize_data);
+ }
++static uint8_t check_length(uint16_t length, uint16_t offset)
++{
++      if (length > BT_ATT_MAX_VALUE_LEN)
++              return BT_ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LEN;
++
++      if (offset > BT_ATT_MAX_VALUE_LEN)
++              return BT_ATT_ERROR_INVALID_OFFSET;
++
++      if (length + offset > BT_ATT_MAX_VALUE_LEN)
++              return BT_ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LEN;
++
++      return 0;
++}
++
+ static void write_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu,
+                                       uint16_t length, void *user_data)
+ {
+@@ -846,6 +860,10 @@ static void write_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu,
+                               (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd",
+                               handle);
++      ecode = check_length(length, 0);
++      if (ecode)
++              goto error;
++
+       ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE_MASK);
+       if (ecode)
+               goto error;
+@@ -1353,6 +1371,10 @@ static void prep_write_cb(struct bt_att_chan *chan, uint8_t opcode,
+       util_debug(server->debug_callback, server->debug_data,
+                               "Prep Write Req - handle: 0x%04x", handle);
++      ecode = check_length(length, offset);
++      if (ecode)
++              goto error;
++
+       ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE_MASK);
+       if (ecode)
+               goto error;