]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.5-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Oct 2023 07:52:30 +0000 (09:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Oct 2023 07:52:30 +0000 (09:52 +0200)
added patches:
bluetooth-hci_sock-correctly-bounds-check-and-pad-hci_mon_new_index-name.patch

queue-6.5/bluetooth-hci_sock-correctly-bounds-check-and-pad-hci_mon_new_index-name.patch [new file with mode: 0644]
queue-6.5/series

diff --git a/queue-6.5/bluetooth-hci_sock-correctly-bounds-check-and-pad-hci_mon_new_index-name.patch b/queue-6.5/bluetooth-hci_sock-correctly-bounds-check-and-pad-hci_mon_new_index-name.patch
new file mode 100644 (file)
index 0000000..0baee62
--- /dev/null
@@ -0,0 +1,65 @@
+From cb3871b1cd135a6662b732fbc6b3db4afcdb4a64 Mon Sep 17 00:00:00 2001
+From: Kees Cook <keescook@chromium.org>
+Date: Wed, 11 Oct 2023 09:31:44 -0700
+Subject: Bluetooth: hci_sock: Correctly bounds check and pad HCI_MON_NEW_INDEX name
+
+From: Kees Cook <keescook@chromium.org>
+
+commit cb3871b1cd135a6662b732fbc6b3db4afcdb4a64 upstream.
+
+The code pattern of memcpy(dst, src, strlen(src)) is almost always
+wrong. In this case it is wrong because it leaves memory uninitialized
+if it is less than sizeof(ni->name), and overflows ni->name when longer.
+
+Normally strtomem_pad() could be used here, but since ni->name is a
+trailing array in struct hci_mon_new_index, compilers that don't support
+-fstrict-flex-arrays=3 can't tell how large this array is via
+__builtin_object_size(). Instead, open-code the helper and use sizeof()
+since it will work correctly.
+
+Additionally mark ni->name as __nonstring since it appears to not be a
+%NUL terminated C string.
+
+Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
+Cc: Edward AD <twuufnxlz@gmail.com>
+Cc: Marcel Holtmann <marcel@holtmann.org>
+Cc: Johan Hedberg <johan.hedberg@gmail.com>
+Cc: "David S. Miller" <davem@davemloft.net>
+Cc: Eric Dumazet <edumazet@google.com>
+Cc: Jakub Kicinski <kuba@kernel.org>
+Cc: Paolo Abeni <pabeni@redhat.com>
+Cc: linux-bluetooth@vger.kernel.org
+Cc: netdev@vger.kernel.org
+Fixes: 18f547f3fc07 ("Bluetooth: hci_sock: fix slab oob read in create_monitor_event")
+Link: https://lore.kernel.org/lkml/202310110908.F2639D3276@keescook/
+Signed-off-by: Kees Cook <keescook@chromium.org>
+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_mon.h |    2 +-
+ net/bluetooth/hci_sock.c        |    3 ++-
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+--- a/include/net/bluetooth/hci_mon.h
++++ b/include/net/bluetooth/hci_mon.h
+@@ -56,7 +56,7 @@ struct hci_mon_new_index {
+       __u8            type;
+       __u8            bus;
+       bdaddr_t        bdaddr;
+-      char            name[8];
++      char            name[8] __nonstring;
+ } __packed;
+ #define HCI_MON_NEW_INDEX_SIZE 16
+--- a/net/bluetooth/hci_sock.c
++++ b/net/bluetooth/hci_sock.c
+@@ -439,7 +439,8 @@ static struct sk_buff *create_monitor_ev
+               ni->type = hdev->dev_type;
+               ni->bus = hdev->bus;
+               bacpy(&ni->bdaddr, &hdev->bdaddr);
+-              memcpy(ni->name, hdev->name, strlen(hdev->name));
++              memcpy_and_pad(ni->name, sizeof(ni->name), hdev->name,
++                             strnlen(hdev->name, sizeof(ni->name)), '\0');
+               opcode = cpu_to_le16(HCI_MON_NEW_INDEX);
+               break;
index 7df5d230a9d259434fc62483937be839310448fe..7aad26a0521c03bc326f3223bd07afa5988ad910 100644 (file)
@@ -236,3 +236,4 @@ bluetooth-hci_sock-fix-slab-oob-read-in-create_monitor_event.patch
 net-rfkill-reduce-data-mtx-scope-in-rfkill_fop_open.patch
 docs-rust-update-rust-docs-output-path.patch
 kbuild-remove-old-rust-docs-output-path.patch
+bluetooth-hci_sock-correctly-bounds-check-and-pad-hci_mon_new_index-name.patch