Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7147336ybi; Mon, 8 Jul 2019 15:35:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyK2t9EdwmBG23Q4vF82IRRV1bWpeA1BiYA2ISn1oykQEVIY9TZBsupJa/zrnNVOuiasTKX X-Received: by 2002:a63:e306:: with SMTP id f6mr26079622pgh.39.1562625329690; Mon, 08 Jul 2019 15:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625329; cv=none; d=google.com; s=arc-20160816; b=F4tsAGR8QfNeLfW7ZRTTdOhinD/P6+Rodd/Zeleu5EePR5h6xc7ZK1Jtxi/ACNPJu3 G3G4CO4WVJMPemPZrDyQ5rkNu/8XZxYmRGpjVD43/TiiUMBygT+mDQ7U/JxcE5Ud4vXF Yq+EmLV38Hc1CBz9N9D7R90BaeO5vRlT8QiLlGPkGf/deemxOKcTfi+fgY3mwaWbvh9k ez2anuZidJBLdqZA3KiTO78xUu3hkC75+rW3Q1kNCZcs37ZG3/EKhponVsnzSGZtLOqe SzwdlOScJoHFrCd/8GT9PmuW+qXuZtvUo8trmab4GILCacsSklaRU8GoTyF3WLhgVRNr bT5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T9K7dgH3kcxQ+uW2xHeg9luysLpA2JF2YzlBD3tQqhI=; b=fYXe6XgYxXkePSoF4r7J7+8StIXe9mGEnIhLpJOFvX6cmCeyycX4/Cn7aly9ZRprVy mCGChJDDCxRHmqLvvjfO27KTrhkjX6ROPk5lHaiehekNk/VyB+uSwKbKbQ7xoZmXRwo5 6zlAcCe9ckCVTsFLIANAN9RnmEfdpwtDvoXY89Fz2lHnyKRIirTW6RIcxQVNIxSsHIYo tSIJe9YMtwAz5nV0f6KM8G+tiaJsd8iYRIbeod81DEWNjes/68I67bJoJdedCnP4ORjB GTaMmEdly4WUgdmGsfKrye3URY2iQ+8KryEt3D0MZlyFHcnhRPjwqmDqftNd++rhsY0J /sAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=reobgoqg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q19si5322076pgg.521.2019.07.08.15.35.14; Mon, 08 Jul 2019 15:35:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=reobgoqg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733304AbfGHPTp (ORCPT + 99 others); Mon, 8 Jul 2019 11:19:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:44160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733290AbfGHPTm (ORCPT ); Mon, 8 Jul 2019 11:19:42 -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 EA307216C4; Mon, 8 Jul 2019 15:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599181; bh=jLuUJzS93NiFBMI63O+Gx7/+lKHwhvNKMTtWX26LwmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=reobgoqgt6qGvaJtI6A5cE1sEuqEuig/nZyKtXUu3/TXKuXlVXPAVnMQs75faF39T /t8/vLJvEQWma8bAiJT+GnhuaPKYeI87zhCLD2R80fMnoB34i+sRnkjxnrdFruCq/i 0qlOyoU3ty+oLFqNHBFWn9zi4veC/UpEi0LX1QIw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcel Holtmann , Johan Hedberg Subject: [PATCH 4.9 031/102] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Date: Mon, 8 Jul 2019 17:12:24 +0200 Message-Id: <20190708150527.955639518@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -176,6 +176,9 @@ struct adv_info { #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 @@ -1165,6 +1165,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; }