From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Marcel Holtmann <marcel@holtmann.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.19 82/90] Bluetooth: Fix regression with minimum encryption key size alignment
Date: Mon, 24 Jun 2019 17:57:12 +0800 [thread overview]
Message-ID: <20190624092319.296342984@linuxfoundation.org> (raw)
In-Reply-To: <20190624092313.788773607@linuxfoundation.org>
From: Marcel Holtmann <marcel@holtmann.org>
commit 693cd8ce3f882524a5d06f7800dd8492411877b3 upstream.
When trying to align the minimum encryption key size requirement for
Bluetooth connections, it turns out doing this in a central location in
the HCI connection handling code is not possible.
Original Bluetooth version up to 2.0 used a security model where the
L2CAP service would enforce authentication and encryption. Starting
with Bluetooth 2.1 and Secure Simple Pairing that model has changed into
that the connection initiator is responsible for providing an encrypted
ACL link before any L2CAP communication can happen.
Now connecting Bluetooth 2.1 or later devices with Bluetooth 2.0 and
before devices are causing a regression. The encryption key size check
needs to be moved out of the HCI connection handling into the L2CAP
channel setup.
To achieve this, the current check inside hci_conn_security() has been
moved into l2cap_check_enc_key_size() helper function and then called
from four decisions point inside L2CAP to cover all combinations of
Secure Simple Pairing enabled devices and device using legacy pairing
and legacy service security model.
Fixes: d5bb334a8e17 ("Bluetooth: Align minimum encryption key size for LE and BR/EDR connections")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203643
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/bluetooth/hci_conn.c | 18 +++++++++---------
net/bluetooth/l2cap_core.c | 33 ++++++++++++++++++++++++++++-----
2 files changed, 37 insertions(+), 14 deletions(-)
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1276,14 +1276,6 @@ int hci_conn_check_link_mode(struct hci_
!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
return 0;
- /* The minimum encryption key size needs to be enforced by the
- * host stack before establishing any L2CAP connections. The
- * specification in theory allows a minimum of 1, but to align
- * BR/EDR and LE transports, a minimum of 7 is chosen.
- */
- if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
- return 0;
-
return 1;
}
@@ -1400,8 +1392,16 @@ auth:
return 0;
encrypt:
- if (test_bit(HCI_CONN_ENCRYPT, &conn->flags))
+ if (test_bit(HCI_CONN_ENCRYPT, &conn->flags)) {
+ /* Ensure that the encryption key size has been read,
+ * otherwise stall the upper layer responses.
+ */
+ if (!conn->enc_key_size)
+ return 0;
+
+ /* Nothing else needed, all requirements are met */
return 1;
+ }
hci_conn_encrypt(conn);
return 0;
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1340,6 +1340,21 @@ static void l2cap_request_info(struct l2
sizeof(req), &req);
}
+static bool l2cap_check_enc_key_size(struct hci_conn *hcon)
+{
+ /* The minimum encryption key size needs to be enforced by the
+ * host stack before establishing any L2CAP connections. The
+ * specification in theory allows a minimum of 1, but to align
+ * BR/EDR and LE transports, a minimum of 7 is chosen.
+ *
+ * This check might also be called for unencrypted connections
+ * that have no key size requirements. Ensure that the link is
+ * actually encrypted before enforcing a key size.
+ */
+ return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) ||
+ hcon->enc_key_size > HCI_MIN_ENC_KEY_SIZE);
+}
+
static void l2cap_do_start(struct l2cap_chan *chan)
{
struct l2cap_conn *conn = chan->conn;
@@ -1357,9 +1372,14 @@ static void l2cap_do_start(struct l2cap_
if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE))
return;
- if (l2cap_chan_check_security(chan, true) &&
- __l2cap_no_conn_pending(chan))
+ if (!l2cap_chan_check_security(chan, true) ||
+ !__l2cap_no_conn_pending(chan))
+ return;
+
+ if (l2cap_check_enc_key_size(conn->hcon))
l2cap_start_connection(chan);
+ else
+ __set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
}
static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask)
@@ -1438,7 +1458,10 @@ static void l2cap_conn_start(struct l2ca
continue;
}
- l2cap_start_connection(chan);
+ if (l2cap_check_enc_key_size(conn->hcon))
+ l2cap_start_connection(chan);
+ else
+ l2cap_chan_close(chan, ECONNREFUSED);
} else if (chan->state == BT_CONNECT2) {
struct l2cap_conn_rsp rsp;
@@ -7455,7 +7478,7 @@ static void l2cap_security_cfm(struct hc
}
if (chan->state == BT_CONNECT) {
- if (!status)
+ if (!status && l2cap_check_enc_key_size(hcon))
l2cap_start_connection(chan);
else
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
@@ -7464,7 +7487,7 @@ static void l2cap_security_cfm(struct hc
struct l2cap_conn_rsp rsp;
__u16 res, stat;
- if (!status) {
+ if (!status && l2cap_check_enc_key_size(hcon)) {
if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) {
res = L2CAP_CR_PEND;
stat = L2CAP_CS_AUTHOR_PEND;
next prev parent reply other threads:[~2019-06-24 10:12 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 9:55 [PATCH 4.19 00/90] 4.19.56-stable review Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 01/90] tracing: Silence GCC 9 array bounds warning Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 02/90] objtool: Support per-function rodata sections Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 03/90] gcc-9: silence address-of-packed-member warning Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 04/90] ovl: support the FS_IOC_FS[SG]ETXATTR ioctls Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 05/90] ovl: fix wrong flags check in " Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 06/90] ovl: make i_ino consistent with st_ino in more cases Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 07/90] ovl: detect overlapping layers Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 08/90] ovl: dont fail with disconnected lower NFS Greg Kroah-Hartman
2019-06-24 9:55 ` [PATCH 4.19 09/90] ovl: fix bogus -Wmaybe-unitialized warning Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 10/90] s390/jump_label: Use "jdd" constraint on gcc9 Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 11/90] s390/ap: rework assembler functions to use unions for in/out register variables Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 12/90] mmc: sdhci: sdhci-pci-o2micro: Correctly set bus width when tuning Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 13/90] mmc: core: API to temporarily disable retuning for SDIO CRC errors Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 14/90] mmc: core: Add sdio_retune_hold_now() and sdio_retune_release() Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 15/90] mmc: core: Prevent processing SDIO IRQs when the card is suspended Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 16/90] scsi: ufs: Avoid runtime suspend possibly being blocked forever Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 17/90] usb: chipidea: udc: workaround for endpoint conflict issue Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 18/90] xhci: detect USB 3.2 capable host controllers correctly Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 19/90] usb: xhci: Dont try to recover an endpoint if port is in error state Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 20/90] IB/hfi1: Validate fault injection opcode user input Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 21/90] IB/hfi1: Silence txreq allocation warnings Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 22/90] iio: temperature: mlx90632 Relax the compatibility check Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 23/90] Input: synaptics - enable SMBus on ThinkPad E480 and E580 Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 24/90] Input: uinput - add compat ioctl number translation for UI_*_FF_UPLOAD Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 25/90] Input: silead - add MSSL0017 to acpi_device_id Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 26/90] apparmor: fix PROFILE_MEDIATES for untrusted input Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 27/90] apparmor: enforce nullbyte at end of tag string Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 28/90] brcmfmac: sdio: Disable auto-tuning around commands expected to fail Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 29/90] brcmfmac: sdio: Dont tune while the card is off Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 30/90] ARC: fix build warnings Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 31/90] dmaengine: dw-axi-dmac: fix null dereference when pointer first is null Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 32/90] dmaengine: sprd: Fix block length overflow Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 33/90] ARC: [plat-hsdk]: Add missing multicast filter bins number to GMAC node Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 34/90] ARC: [plat-hsdk]: Add missing FIFO size entry in " Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 35/90] fpga: dfl: afu: Pass the correct device to dma_mapping_error() Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 36/90] fpga: dfl: Add lockdep classes for pdata->lock Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 37/90] parport: Fix mem leak in parport_register_dev_model Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 38/90] parisc: Fix compiler warnings in float emulation code Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 39/90] IB/rdmavt: Fix alloc_qpn() WARN_ON() Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 40/90] IB/hfi1: Insure freeze_work work_struct is canceled on shutdown Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 41/90] IB/{qib, hfi1, rdmavt}: Correct ibv_devinfo max_mr value Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 42/90] IB/hfi1: Validate page aligned for a given virtual address Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 43/90] MIPS: uprobes: remove set but not used variable epc Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 44/90] xtensa: Fix section mismatch between memblock_reserve and mem_reserve Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 45/90] kselftest/cgroup: fix unexpected testing failure on test_memcontrol Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 46/90] kselftest/cgroup: fix unexpected testing failure on test_core Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 47/90] kselftest/cgroup: fix incorrect test_core skip Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 48/90] selftests: vm: install test_vmalloc.sh for run_vmtests Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 49/90] net: dsa: mv88e6xxx: avoid error message on remove from VLAN 0 Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 50/90] net: hns: Fix loopback test failed at copper ports Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 51/90] mdesc: fix a missing-check bug in get_vdev_port_node_info() Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 52/90] sparc: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 53/90] net: ethernet: mediatek: Use hw_feature to judge if HWLRO is supported Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 54/90] net: ethernet: mediatek: Use NET_IP_ALIGN to judge if HW RX_2BYTE_OFFSET is enabled Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 55/90] drm/arm/mali-dp: Add a loop around the second set CVAL and try 5 times Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 56/90] drm/arm/hdlcd: Actually validate CRTC modes Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 57/90] drm/arm/hdlcd: Allow a bit of clock tolerance Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 58/90] nvmet: fix data_len to 0 for bdev-backed write_zeroes Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 59/90] scripts/checkstack.pl: Fix arm64 wrong or unknown architecture Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 60/90] scsi: ufs: Check that space was properly alloced in copy_query_response Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 61/90] scsi: smartpqi: unlock on error in pqi_submit_raid_request_synchronous() Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 62/90] net: ipvlan: Fix ipvlan device tso disabled while NETIF_F_IP_CSUM is set Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 63/90] s390/qeth: fix VLAN attribute in bridge_hostnotify udev event Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 64/90] hwmon: (core) add thermal sensors only if dev->of_node is present Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 65/90] hwmon: (pmbus/core) Treat parameters as paged if on multiple pages Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 66/90] arm64: Silence gcc warnings about arch ABI drift Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 67/90] nvme: Fix u32 overflow in the number of namespace list calculation Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 68/90] btrfs: start readahead also in seed devices Greg Kroah-Hartman
2019-06-24 9:56 ` [PATCH 4.19 69/90] can: xilinx_can: use correct bittiming_const for CAN FD core Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 70/90] can: flexcan: fix timeout when set small bitrate Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 71/90] can: purge socket error queue on sock destruct Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 72/90] riscv: mm: synchronize MMU after pte change Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 73/90] powerpc/bpf: use unsigned division instruction for 64-bit operations Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 74/90] ARM: imx: cpuidle-imx6sx: Restrict the SW2ISO increase to i.MX6SX Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 75/90] ARM: dts: dra76x: Update MMC2_HS200_MANUAL1 iodelay values Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 76/90] ARM: dts: am57xx-idk: Remove support for voltage switching for SD card Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 77/90] arm64/sve: <uapi/asm/ptrace.h> should not depend on <uapi/linux/prctl.h> Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 78/90] arm64: ssbd: explicitly depend on <linux/prctl.h> Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 79/90] drm/vmwgfx: Use the backdoor port if the HB port is not available Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 80/90] staging: erofs: add requirements field in superblock Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 81/90] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Greg Kroah-Hartman
2019-06-24 9:57 ` Greg Kroah-Hartman [this message]
2019-06-24 9:57 ` [PATCH 4.19 83/90] SMB3: retry on STATUS_INSUFFICIENT_RESOURCES instead of failing write Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 84/90] cfg80211: fix memory leak of wiphy device name Greg Kroah-Hartman
2019-06-25 21:51 ` Pavel Machek
2019-06-25 22:33 ` Eric Biggers
2019-06-24 9:57 ` [PATCH 4.19 85/90] mac80211: drop robust management frames from unknown TA Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 86/90] {nl,mac}80211: allow 4addr AP operation on crypto controlled devices Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 87/90] mac80211: handle deauthentication/disassociation from TDLS peer Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 88/90] nl80211: fix station_info pertid memory leak Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 89/90] mac80211: Do not use stack memory with scatterlist for GMAC Greg Kroah-Hartman
2019-06-24 9:57 ` [PATCH 4.19 90/90] x86/resctrl: Dont stop walking closids when a locksetup group is found Greg Kroah-Hartman
2019-06-24 15:11 ` [PATCH 4.19 00/90] 4.19.56-stable review kernelci.org bot
2019-06-25 0:14 ` Guenter Roeck
2019-06-25 0:43 ` Naresh Kamboju
2019-06-25 10:00 ` 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=20190624092319.296342984@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).