]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 May 2022 08:28:48 +0000 (10:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 May 2022 08:28:48 +0000 (10:28 +0200)
added patches:
bluetooth-fix-the-creation-of-hdev-name.patch

queue-5.10/bluetooth-fix-the-creation-of-hdev-name.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/bluetooth-fix-the-creation-of-hdev-name.patch b/queue-5.10/bluetooth-fix-the-creation-of-hdev-name.patch
new file mode 100644 (file)
index 0000000..217d5d7
--- /dev/null
@@ -0,0 +1,65 @@
+From 103a2f3255a95991252f8f13375c3a96a75011cd Mon Sep 17 00:00:00 2001
+From: Itay Iellin <ieitayie@gmail.com>
+Date: Sat, 7 May 2022 08:32:48 -0400
+Subject: Bluetooth: Fix the creation of hdev->name
+
+From: Itay Iellin <ieitayie@gmail.com>
+
+commit 103a2f3255a95991252f8f13375c3a96a75011cd upstream.
+
+Set a size limit of 8 bytes of the written buffer to "hdev->name"
+including the terminating null byte, as the size of "hdev->name" is 8
+bytes. If an id value which is greater than 9999 is allocated,
+then the "snprintf(hdev->name, sizeof(hdev->name), "hci%d", id)"
+function call would lead to a truncation of the id value in decimal
+notation.
+
+Set an explicit maximum id parameter in the id allocation function call.
+The id allocation function defines the maximum allocated id value as the
+maximum id parameter value minus one. Therefore, HCI_MAX_ID is defined
+as 10000.
+
+Signed-off-by: Itay Iellin <ieitayie@gmail.com>
+Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/net/bluetooth/hci_core.h |    3 +++
+ net/bluetooth/hci_core.c         |    6 +++---
+ 2 files changed, 6 insertions(+), 3 deletions(-)
+
+--- a/include/net/bluetooth/hci_core.h
++++ b/include/net/bluetooth/hci_core.h
+@@ -35,6 +35,9 @@
+ /* HCI priority */
+ #define HCI_PRIO_MAX  7
++/* HCI maximum id value */
++#define HCI_MAX_ID 10000
++
+ /* HCI Core structures */
+ struct inquiry_data {
+       bdaddr_t        bdaddr;
+--- a/net/bluetooth/hci_core.c
++++ b/net/bluetooth/hci_core.c
+@@ -3718,10 +3718,10 @@ int hci_register_dev(struct hci_dev *hde
+        */
+       switch (hdev->dev_type) {
+       case HCI_PRIMARY:
+-              id = ida_simple_get(&hci_index_ida, 0, 0, GFP_KERNEL);
++              id = ida_simple_get(&hci_index_ida, 0, HCI_MAX_ID, GFP_KERNEL);
+               break;
+       case HCI_AMP:
+-              id = ida_simple_get(&hci_index_ida, 1, 0, GFP_KERNEL);
++              id = ida_simple_get(&hci_index_ida, 1, HCI_MAX_ID, GFP_KERNEL);
+               break;
+       default:
+               return -EINVAL;
+@@ -3730,7 +3730,7 @@ int hci_register_dev(struct hci_dev *hde
+       if (id < 0)
+               return id;
+-      sprintf(hdev->name, "hci%d", id);
++      snprintf(hdev->name, sizeof(hdev->name), "hci%d", id);
+       hdev->id = id;
+       BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
index 8a96b6deda57b059a3494b597f16f4e73cd43bb6..7d85a5297e1c5b1d2ea86085b39b59b56de61a7c 100644 (file)
@@ -4,3 +4,4 @@ block-drbd-drbd_nl-make-conversion-to-enum-drbd_ret_code-explicit.patch
 drm-amd-display-dc-gpio-gpio_service-pass-around-correct-dce_-version-environment-types.patch
 nfp-bpf-silence-bitwise-vs.-logical-or-warning.patch
 arm-remove-config_arch_has_holes_memorymodel.patch
+bluetooth-fix-the-creation-of-hdev-name.patch