android_kernel_motorola_sm6225/net/bluetooth
Arnd Bergmann 5afc7720e7 Bluetooth: avoid memcmp() out of bounds warning
commit 9d1a3c74746428102d55371fbf74b484733937d9 upstream.

bacmp() is a wrapper around memcpy(), which contain compile-time
checks for buffer overflow. Since the hci_conn_request_evt() also calls
bt_dev_dbg() with an implicit NULL pointer check, the compiler is now
aware of a case where 'hdev' is NULL and treats this as meaning that
zero bytes are available:

In file included from net/bluetooth/hci_event.c:32:
In function 'bacmp',
    inlined from 'hci_conn_request_evt' at net/bluetooth/hci_event.c:3276:7:
include/net/bluetooth/bluetooth.h:364:16: error: 'memcmp' specified bound 6 exceeds source size 0 [-Werror=stringop-overread]
  364 |         return memcmp(ba1, ba2, sizeof(bdaddr_t));
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add another NULL pointer check before the bacmp() to ensure the compiler
understands the code flow enough to not warn about it.  Since the patch
that introduced the warning is marked for stable backports, this one
should also go that way to avoid introducing build regressions.

Fixes: 1ffc6f8cc332 ("Bluetooth: Reject connection with the device which has same BD_ADDR")
Cc: Kees Cook <keescook@chromium.org>
Cc: "Lee, Chun-Yi" <jlee@suse.com>
Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-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>
2023-10-25 11:16:41 +02:00
..
bnep
cmtp Bluetooth: cmtp: fix possible panic when cmtp_init_sockets() fails 2022-01-27 09:04:16 +01:00
hidp Bluetooth: Fix race condition in hidp_session_thread 2023-04-20 12:04:39 +02:00
rfcomm Bluetooth: RFCOMM: don't call kfree_skb() under spin_lock_irqsave() 2023-01-18 11:30:20 +01:00
6lowpan.c Bluetooth: 6LoWPAN: add missing hci_dev_put() in get_l2cap_conn() 2022-12-14 11:28:28 +01:00
a2mp.c Bluetooth: drop HCI device reference before return 2021-03-04 09:39:34 +01:00
a2mp.h
af_bluetooth.c Bluetooth: Fix not cleanup led when bt_init fails 2022-12-14 11:28:28 +01:00
amp.c Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data 2021-03-07 12:18:58 +01:00
amp.h
ecdh_helper.c
ecdh_helper.h Fix misc new gcc warnings 2021-05-22 10:59:21 +02:00
hci_conn.c Bluetooth: Reject connection with the device which has same BD_ADDR 2023-10-25 11:16:39 +02:00
hci_core.c Bluetooth: Fix use-after-free in hci_remove_ltk/hci_remove_irk 2023-06-14 10:57:14 +02:00
hci_debugfs.c
hci_debugfs.h
hci_event.c Bluetooth: avoid memcmp() out of bounds warning 2023-10-25 11:16:41 +02:00
hci_request.c bluetooth: eliminate the potential race condition when removing the HCI controller 2021-05-22 10:59:24 +02:00
hci_request.h Bluetooth: Ignore CC events not matching the last HCI command 2019-05-31 06:46:09 -07:00
hci_sock.c bluetooth: Add cmd validity checks at the start of hci_sock_ioctl() 2023-06-09 10:23:54 +02:00
hci_sysfs.c Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times 2022-10-26 13:19:37 +02:00
Kconfig
l2cap_core.c Bluetooth: L2CAP: Fix use-after-free 2023-08-30 16:31:43 +02:00
l2cap_sock.c Bluetooth: L2CAP: Fix use-after-free in l2cap_sock_ready_cb 2023-08-11 11:45:39 +02:00
leds.c
leds.h
lib.c
Makefile
mgmt.c Bluetooth: Fix the HCI to MGMT status conversion table 2021-07-20 16:16:02 +02:00
mgmt_util.c
mgmt_util.h
sco.c Bluetooth: SCO: Fix sco_send_frame returning skb->len 2022-07-29 17:10:36 +02:00
selftest.c
selftest.h
smp.c Bluetooth: SMP: Fail if remote and local public keys are identical 2021-05-26 11:48:36 +02:00
smp.h