public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 82/98] Bluetooth: hci_event: Fix using memcmp when comparing keys
Date: Mon, 23 Oct 2023 12:57:11 +0200	[thread overview]
Message-ID: <20231023104816.445892418@linuxfoundation.org> (raw)
In-Reply-To: <20231023104813.580375891@linuxfoundation.org>

4.19-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit b541260615f601ae1b5d6d0cc54e790de706303b ]

memcmp is not consider safe to use with cryptographic secrets:

 'Do  not  use memcmp() to compare security critical data, such as
 cryptographic secrets, because the required CPU time depends on the
 number of equal bytes.'

While usage of memcmp for ZERO_KEY may not be considered a security
critical data, it can lead to more usage of memcmp with pairing keys
which could introduce more security problems.

Fixes: 455c2ff0a558 ("Bluetooth: Fix BR/EDR out-of-band pairing with only initiator data")
Fixes: 33155c4aae52 ("Bluetooth: hci_event: Ignore NULL link key")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_event.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 843502783b268..8b59f7808628a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -25,6 +25,8 @@
 /* Bluetooth HCI event handling. */
 
 #include <asm/unaligned.h>
+#include <linux/crypto.h>
+#include <crypto/algapi.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -3827,7 +3829,7 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
 		goto unlock;
 
 	/* Ignore NULL link key against CVE-2020-26555 */
-	if (!memcmp(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) {
+	if (!crypto_memneq(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) {
 		bt_dev_dbg(hdev, "Ignore NULL link key (ZERO KEY) for %pMR",
 			   &ev->bdaddr);
 		hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
@@ -4313,8 +4315,8 @@ static u8 bredr_oob_data_present(struct hci_conn *conn)
 		 * available, then do not declare that OOB data is
 		 * present.
 		 */
-		if (!memcmp(data->rand256, ZERO_KEY, 16) ||
-		    !memcmp(data->hash256, ZERO_KEY, 16))
+		if (!crypto_memneq(data->rand256, ZERO_KEY, 16) ||
+		    !crypto_memneq(data->hash256, ZERO_KEY, 16))
 			return 0x00;
 
 		return 0x02;
@@ -4324,8 +4326,8 @@ static u8 bredr_oob_data_present(struct hci_conn *conn)
 	 * not supported by the hardware, then check that if
 	 * P-192 data values are present.
 	 */
-	if (!memcmp(data->rand192, ZERO_KEY, 16) ||
-	    !memcmp(data->hash192, ZERO_KEY, 16))
+	if (!crypto_memneq(data->rand192, ZERO_KEY, 16) ||
+	    !crypto_memneq(data->hash192, ZERO_KEY, 16))
 		return 0x00;
 
 	return 0x01;
-- 
2.40.1




  parent reply	other threads:[~2023-10-23 11:18 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 10:55 [PATCH 4.19 00/98] 4.19.297-rc1 review Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 01/98] indirect call wrappers: helpers to speed-up indirect calls of builtin Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 02/98] net: use indirect calls helpers at the socket layer Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 03/98] net: fix kernel-doc warnings for socket.c Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 04/98] net: prevent rewrite of msg_name in sock_sendmsg() Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 05/98] RDMA/cxgb4: Check skb value for failure to allocate Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 06/98] platform/x86: hp-wmi:: Mark driver struct with __refdata to prevent section mismatch warning Greg Kroah-Hartman
2023-10-23 16:40   ` Uwe Kleine-König
2023-10-24  7:50     ` Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 07/98] HID: logitech-hidpp: Fix kernel crash on receiver USB disconnect Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 08/98] quota: Fix slow quotaoff Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 09/98] net: prevent address rewrite in kernel_bind() Greg Kroah-Hartman
2023-10-23 10:55 ` [PATCH 4.19 10/98] drm: etvnaviv: fix bad backport leading to warning Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 11/98] drm/msm/dsi: skip the wait for video mode done if not applicable Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 12/98] ieee802154: ca8210: Fix a potential UAF in ca8210_probe Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 13/98] xen-netback: use default TX queue size for vifs Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 14/98] drm/vmwgfx: fix typo of sizeof argument Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 15/98] ixgbe: fix crash with empty VF macvlan list Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 16/98] net: nfc: fix races in nfc_llcp_sock_get() and nfc_llcp_sock_get_sn() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 17/98] nfc: nci: assert requested protocol is valid Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 18/98] workqueue: Override implicit ordered attribute in workqueue_apply_unbound_cpumask() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 19/98] sched,idle,rcu: Push rcu_idle deeper into the idle path Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 20/98] dmaengine: stm32-mdma: abort resume if no ongoing transfer Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 21/98] usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 22/98] net: usb: dm9601: fix uninitialized variable use in dm9601_mdio_read Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 23/98] usb: dwc3: Soft reset phy on probe for host Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 24/98] usb: musb: Get the musb_qh poniter after musb_giveback Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 25/98] usb: musb: Modify the "HWVers" register address Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 26/98] iio: pressure: bmp280: Fix NULL pointer exception Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 27/98] iio: pressure: ms5611: ms5611_prom_is_valid false negative bug Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 28/98] mcb: remove is_added flag from mcb_device struct Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 29/98] ceph: fix incorrect revoked caps assert in ceph_fill_file_size() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 30/98] Input: powermate - fix use-after-free in powermate_config_complete Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 31/98] Input: psmouse - fix fast_reconnect function for PS/2 mode Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 32/98] Input: xpad - add PXN V900 support Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 33/98] cgroup: Remove duplicates in cgroup v1 tasks file Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 34/98] pinctrl: avoid unsafe code pattern in find_pinctrl() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 35/98] x86/cpu: Fix AMD erratum #1485 on Zen4-based CPUs Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 36/98] usb: gadget: udc-xilinx: replace memcpy with memcpy_toio Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 37/98] usb: gadget: ncm: Handle decoding of multiple NTBs in unwrap call Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 38/98] powerpc/64e: Fix wrong test in __ptep_test_and_clear_young() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 39/98] x86/alternatives: Disable KASAN in apply_alternatives() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 40/98] dev_forward_skb: do not scrub skb mark within the same name space Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 41/98] usb: hub: Guard against accesses to uninitialized BOS descriptors Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 42/98] Bluetooth: hci_event: Ignore NULL link key Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 43/98] Bluetooth: Reject connection with the device which has same BD_ADDR Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 44/98] Bluetooth: Fix a refcnt underflow problem for hci_conn Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 45/98] Bluetooth: vhci: Fix race when opening vhci device Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 46/98] Bluetooth: hci_event: Fix coding style Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 47/98] Bluetooth: avoid memcmp() out of bounds warning Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 48/98] nfc: nci: fix possible NULL pointer dereference in send_acknowledge() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 49/98] regmap: fix NULL deref on lookup Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 50/98] KVM: x86: Mask LVTPC when handling a PMI Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 51/98] netfilter: nft_payload: fix wrong mac header matching Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 52/98] xfrm: fix a data-race in xfrm_gen_index() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 53/98] xfrm: interface: use DEV_STATS_INC() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 54/98] net: ipv4: fix return value check in esp_remove_trailer Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 55/98] net: ipv6: " Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 56/98] net: rfkill: gpio: prevent value glitch during probe Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 57/98] tcp: fix excessive TLP and RACK timeouts from HZ rounding Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 58/98] tcp: tsq: relax tcp_small_queue_check() when rtx queue contains a single skb Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 59/98] net: usb: smsc95xx: Fix an error code in smsc95xx_reset() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 60/98] i40e: prevent crash on probe if hw registers have invalid values Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 61/98] net/sched: sch_hfsc: upgrade rt to sc when it becomes a inner curve Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 62/98] netfilter: nft_set_rbtree: .deactivate fails if element has expired Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 63/98] net: pktgen: Fix interface flags printing Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 64/98] libceph: fix unaligned accesses in ceph_entity_addr handling Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 65/98] libceph: use kernel_connect() Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 66/98] ARM: dts: ti: omap: Fix noisy serial with overrun-throttle-ms for mapphone Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 67/98] btrfs: return -EUCLEAN for delayed tree ref with a ref count not equals to 1 Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 68/98] btrfs: initialize start_slot in btrfs_log_prealloc_extents Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 69/98] i2c: mux: Avoid potential false error message in i2c_mux_add_adapter Greg Kroah-Hartman
2023-10-23 10:56 ` [PATCH 4.19 70/98] overlayfs: set ctime when setting mtime and atime Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 71/98] gpio: timberdale: Fix potential deadlock on &tgpio->lock Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 72/98] ata: libata-eh: Fix compilation warning in ata_eh_link_report() Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 73/98] tracing: relax trace_event_eval_update() execution with cond_resched() Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 74/98] HID: holtek: fix slab-out-of-bounds Write in holtek_kbd_input_event Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 75/98] Bluetooth: Avoid redundant authentication Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 76/98] Bluetooth: hci_core: Fix build warnings Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 77/98] wifi: mac80211: allow transmitting EAPOL frames with tainted key Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 78/98] wifi: cfg80211: avoid leaking stack data into trace Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 79/98] sky2: Make sure there is at least one frag_addr available Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 80/98] drm: panel-orientation-quirks: Add quirk for One Mix 2S Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 81/98] btrfs: fix some -Wmaybe-uninitialized warnings in ioctl.c Greg Kroah-Hartman
2023-10-23 10:57 ` Greg Kroah-Hartman [this message]
2023-10-23 10:57 ` [PATCH 4.19 83/98] mtd: rawnand: qcom: Unmap the right resource upon probe failure Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 84/98] mtd: spinand: micron: correct bitmask for ecc status Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 85/98] mmc: core: Capture correct oemid-bits for eMMC cards Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 86/98] Revert "pinctrl: avoid unsafe code pattern in find_pinctrl()" Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 87/98] ACPI: irq: Fix incorrect return value in acpi_register_gsi() Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 88/98] USB: serial: option: add Telit LE910C4-WWX 0x1035 composition Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 89/98] USB: serial: option: add entry for Sierra EM9191 with new firmware Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 90/98] USB: serial: option: add Fibocom to DELL custom modem FM101R-GL Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 91/98] perf: Disallow mis-matched inherited group reads Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 92/98] s390/pci: fix iommu bitmap allocation Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 93/98] gpio: vf610: set value before the direction to avoid a glitch Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 94/98] ASoC: pxa: fix a memory leak in probe() Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 95/98] phy: mapphone-mdm6600: Fix runtime PM for remove Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 96/98] Bluetooth: hci_sock: fix slab oob read in create_monitor_event Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 97/98] Bluetooth: hci_sock: Correctly bounds check and pad HCI_MON_NEW_INDEX name Greg Kroah-Hartman
2023-10-23 10:57 ` [PATCH 4.19 98/98] xfrm6: fix inet6_dev refcount underflow problem Greg Kroah-Hartman
2023-10-23 20:42 ` [PATCH 4.19 00/98] 4.19.297-rc1 review Pavel Machek
2023-10-24  8:34 ` Daniel Díaz
2023-10-24  8:58 ` Sudip Mukherjee (Codethink)
2023-10-24 18:11 ` Guenter Roeck
2023-10-25 18:57 ` Jon Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231023104816.445892418@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox