From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12EC7C04E53 for ; Wed, 15 May 2019 12:18:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CED8E2082E for ; Wed, 15 May 2019 12:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922688; bh=OvEl4UsmlhWXmcia5fYSXpCkmXK8IQS5m5jQPWfQbQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uwU5KY6YdDUbMDHFVwPA2J4cjPpRx4DPCurU1b9VZ5TDUtvLabcb3VBcmOTY70mk8 o7ObbOMlRoF2qZaYhljI2nTeRCRtG4RoH7etq/905PpN/RWlKoK8/0ope6jpSL7KQn 9YGoqmjwH5/QF9wjNEu2jczrPkgN2qDU9jWzFXIU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727208AbfEOLBb (ORCPT ); Wed, 15 May 2019 07:01:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:58524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727699AbfEOLBa (ORCPT ); Wed, 15 May 2019 07:01:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 26B26216FD; Wed, 15 May 2019 11:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918089; bh=OvEl4UsmlhWXmcia5fYSXpCkmXK8IQS5m5jQPWfQbQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1dsCVT+g9Gt/4xJVpf8s3A9lOEyyT7bvTHo1ldGmYV+d3/fAiUI0wjAmnZv9ftES7 lYDK/IZ2+/sMnNuKuwMzjYxoyNhDNpkKRYB+IIE96khfqKoJNX/sBwV6Kdz/sTD7/R TObcJaw5wN6THYDrH7ic6ILzRiMvD0pMp7CQ643M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcel Holtmann , Johan Hedberg Subject: [PATCH 3.18 61/86] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Date: Wed, 15 May 2019 12:55:38 +0200 Message-Id: <20190515090654.396891161@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090642.339346723@linuxfoundation.org> References: <20190515090642.339346723@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marcel Holtmann commit d5bb334a8e171b262e48f378bd2096c0ea458265 upstream. The minimum encryption key size for LE connections is 56 bits and to align LE with BR/EDR, enforce 56 bits of minimum encryption key size for BR/EDR connections as well. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_conn.c | 8 ++++++++ 2 files changed, 11 insertions(+) --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -145,6 +145,9 @@ struct oob_data { #define HCI_MAX_SHORT_NAME_LENGTH 10 +/* Min encryption key size to match with SMP */ +#define HCI_MIN_ENC_KEY_SIZE 7 + /* Default LE RPA expiry time, 15 minutes */ #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60) --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -932,6 +932,14 @@ 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; }