Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1501115pxb; Fri, 26 Feb 2021 12:23:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHUg32Gpmd4Y8NZ2ivv4RiU9wt+P78i6Dt7dT1ek+BYpIgjNfsaQ0mWbfb2GftH6y5nIbq X-Received: by 2002:a17:906:1848:: with SMTP id w8mr5155818eje.3.1614371018923; Fri, 26 Feb 2021 12:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614371018; cv=none; d=google.com; s=arc-20160816; b=DUJQjsBipCzWkYmLmQzrP0w7dGdBwUiQCkP/qbPG0XNo+srZVZZ0OuMNwODO6Xrbzw YEm8r/8qzcv8kuEQNVpCKPrvmGKRjLkuEw5TMe5t+ZcnMyVn3qUvLDUC53edDHmtJolP u+RdJB2vH8cSsi0tSI2dOnyJ+6M/KtOjHLRLaRfswh+tryFyI11HGS2zHHoR4VjNaE3g VfpypCQqoz42kslAXvfqyZIycbHhAWfuftVDkcdQdlyh7DW4LUYSzUGhT3Wnhj9YUCS2 TkEmOe0HiAtHKZxsVmNZhAfsJQ6MhJ3v/dN0Ne7uaMBrhZPkoLOcrMfvKi/MW+8myhBW Q2HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=P73uMphZvkxj6Sswz4ONDEj6lRvJ+QdDS+Yn92BpzSg=; b=ca5+U7jpRjc8G/0L5OZ5a4LHI+6D7MM1JQoTK2/V4OKIg0oEQzJWlSSc9rCYWvJfvu iKZkRilD8I//Krd+lbePc36La4Po0he7Df4NqEtnzHhb1iMCNLgUV6S3cOtYGmsH16SV Ykb6gkDwQ6wiD68vE5cAIiiYwyV3gQea+os8e67AURBiFDhgbmwtxKLu87xtzrGhW8rS V5LBNveET1McmU19m5F8Uz/f3UJ2hACYbVKDnpwDjQuJQBB+DfrmVdF7HLFjm86XW2qX p+O56HHt6heMnvptnILpObrQ8glLx1QfQ/eC7Xo2Iz0oo+N/ORSQ/0U9w//FUILvunxk MFhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k18si1723920eja.602.2021.02.26.12.23.16; Fri, 26 Feb 2021 12:23:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231185AbhBZUTw convert rfc822-to-8bit (ORCPT + 99 others); Fri, 26 Feb 2021 15:19:52 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:43418 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231506AbhBZUSD (ORCPT ); Fri, 26 Feb 2021 15:18:03 -0500 Received: from marcel-macbook.holtmann.net (p4ff9fb90.dip0.t-ipconnect.de [79.249.251.144]) by mail.holtmann.org (Postfix) with ESMTPSA id CE57FCEC82; Fri, 26 Feb 2021 21:24:52 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: [PATCH] Bluetooth: Fix for L2CAP/LE/CFC/BV-15-C From: Marcel Holtmann In-Reply-To: <20210222103021.20923-1-magdalena.kasenberg@codecoup.pl> Date: Fri, 26 Feb 2021 21:17:19 +0100 Cc: Bluetooth Kernel Mailing List , Szymon Janc Content-Transfer-Encoding: 8BIT Message-Id: <124AEB1E-158A-4CFB-BD5D-2DCA4C86ECD2@holtmann.org> References: <20210222103021.20923-1-magdalena.kasenberg@codecoup.pl> To: Magdalena Kasenberg X-Mailer: Apple Mail (2.3654.60.0.2.21) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Magdalena, > This is required for the qualification test L2CAP/LE/CFC/BV-15-C > > Implementation does not allow to set different key size for SMP and > L2CAP, which is needed for a current specification of the test. This fix > workarounds it with the debugfs variable le_l2cap_min_key_size. > > Logs from the test when the IUT uses a min and max l2cap encryption key size 16. > $ echo 16 > /sys/kernel/debug/bluetooth/hci0/le_l2cap_min_key_size > The lower tester uses a key size 7. > >> ACL Data RX: Handle 99 flags 0x02 dlen 11 #34 [hci0] 25.007392 > SMP: Pairing Request (0x01) len 6 > IO capability: DisplayYesNo (0x01) > OOB data: Authentication data not present (0x00) > Authentication requirement: Bonding, No MITM, SC, No Keypresses (0x09) > Max encryption key size: 7 > Initiator key distribution: (0x00) > Responder key distribution: (0x00) > < ACL Data TX: Handle 99 flags 0x00 dlen 11 #35 [hci0] 25.007591 > SMP: Pairing Response (0x02) len 6 > IO capability: KeyboardDisplay (0x04) > OOB data: Authentication data not present (0x00) > Authentication requirement: Bonding, No MITM, SC, No Keypresses (0x09) > Max encryption key size: 16 > Initiator key distribution: (0x00) > Responder key distribution: (0x00) > @ MGMT Event: New Long Term Key (0x000a) plen 37 {0x0001} [hci0] 28.788872 > Store hint: Yes (0x01) > LE Address: C0:DE:C0:FF:FF:01 (OUI C0-DE-C0) > Key type: Unauthenticated key from P-256 (0x02) > Master: 0x00 > Encryption size: 7 > Diversifier: 0000 > Randomizer: 0000000000000000 > Key: 529e11e8c7b9f5000000000000000000 > > > > After pairing with key size 7, L2CAP connection is requested which > requires key size 16. > >> ACL Data RX: Handle 99 flags 0x02 dlen 18 #56 [hci0] 34.998084 > LE L2CAP: LE Connection Request (0x14) ident 3 len 10 > PSM: 244 (0x00f4) > Source CID: 64 > MTU: 256 > MPS: 284 > Credits: 1 > < ACL Data TX: Handle 99 flags 0x00 dlen 18 #57 [hci0] 34.998325 > LE L2CAP: LE Connection Response (0x15) ident 3 len 10 > Destination CID: 0 > MTU: 0 > MPS: 0 > Credits: 0 > Result: Connection refused - insufficient encryption key size (0x0007) > > Signed-off-by: Magdalena Kasenberg > Reviewed-by: Szymon Janc > Cc: Szymon Janc > --- > include/net/bluetooth/hci_core.h | 1 + > net/bluetooth/hci_core.c | 1 + > net/bluetooth/hci_debugfs.c | 30 ++++++++++++++++++++++++++++++ > net/bluetooth/l2cap_core.c | 25 +++++++++++++++++++++++++ > 4 files changed, 57 insertions(+) > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index ebdd4afe30d2..0bf0543efec5 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -379,6 +379,7 @@ struct hci_dev { > __u16 auth_payload_timeout; > __u8 min_enc_key_size; > __u8 max_enc_key_size; > + __u8 le_l2cap_min_key_size; > __u8 pairing_opts; > __u8 ssp_debug_mode; > __u8 hw_error_code; > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index b0d9c36acc03..9ef4b39b380c 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3788,6 +3788,7 @@ struct hci_dev *hci_alloc_dev(void) > hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE; > hdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT; > hdev->min_enc_key_size = HCI_MIN_ENC_KEY_SIZE; > + hdev->le_l2cap_min_key_size = HCI_MIN_ENC_KEY_SIZE; so I am not a fan of doing this with another variable and managing through debugfs. Can we pass the qualification test case by using BT_SECURITY_FIPS (which will enforce 128-bit key size)? If not then we might want to add a socket option to set min/max encryption key size requirement on a per socket basis. Regards Marcel