Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2255413ybd; Mon, 24 Jun 2019 03:24:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYjfzoxWA/x29A+B0irDYWKDTQG6vKjNc502tzdWMNa5+WU3DTrV0L25b3MJqZ6k6FaRuo X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr23934065pjl.78.1561371848256; Mon, 24 Jun 2019 03:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371848; cv=none; d=google.com; s=arc-20160816; b=tnCf0r1wF/ZJjJnOADdVKja6LBLDN68k3YBXmGmoFO/IK8gcEFkO9jT9rPruHt0B77 Yab6i4gG2xql5ODeBg8IkDUD6Qd2EKaW3Rzv1d8hZNmlLXt0QhjWJKaJei9vqtNsk8zw /Xd4pcYv7l+sLwC6FkZlk9ffGLwM7yhI0EBNIuoqecTy7kKxPhP3WAuXlW6ViijRSodF yrLeYR/BWHSjjyQjGZtcGVvvic9NiOQ1m2LvYz2FndEHbR9Szoq2wyXArNtBb/ERbrc0 75rF20knFn4m/eLozTxtrVHwD7EY3GU2ABPy/N4KxSNo7pj9Prj9XnEUlnJUY6RMhWol NS0Q== 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=+alBzIAT9JrUjJbczsZ3wULgkMirbZlm0/IQ1okPAPk=; b=QEOVcRu+JPrMI5aDp+ytMuIzkkt01VrcE3JaFoC1lPLuiO1MWJcMt5iVIyAd2z4Wx5 ig3igW+8dL3VzDeF4UjJbTkT1BVhHg0v8hAnbeA+Uo7vfUGWmTj27cUuXIDhvG0IaVQ2 o5x84ENifV3iuPiHn6FRgOB6cWWEhbhckamYvcVW7VLgjTQXhEV18g5uROK00U80agDQ BGnbI6bpwDKjfv6snSPayIpmOc8FqddCDG/ZRTMWSaZuzvMsC8q/Soo6pvlWjGL7PFse zLD+Qevdwe3zRhFqMu+BzsChQJWtxTfsbq3yoW43JGMwwXhPBTKl197O2eKvidWpaOvG 32uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QSEQiSpn; 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 h4si9758307pjs.103.2019.06.24.03.23.52; Mon, 24 Jun 2019 03:24:08 -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=QSEQiSpn; 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 S1731053AbfFXKWH (ORCPT + 99 others); Mon, 24 Jun 2019 06:22:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:57870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731032AbfFXKWE (ORCPT ); Mon, 24 Jun 2019 06:22:04 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (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 159DC2146E; Mon, 24 Jun 2019 10:22:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371723; bh=vXxZdof0fj3EGo3Sl0TaM9lj10tLhaQcGMTDjVs0RdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QSEQiSpnR1zbwi5BIkylSlDf7BgfOnz//hf0beUnH9obofYASLT5eV9dUm9lwlhnl NOahKRhmVrhFh+icIOItmlu/aR6Zf2luV7mNDYIzn+7+QWq+T68BxDT4MFZZIc1E4D g+cxwJfrMMRe9eRVusAp7lUzfRBw+VoscTBt1LH8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcel Holtmann , Johan Hedberg Subject: [PATCH 5.1 110/121] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Date: Mon, 24 Jun 2019 17:57:22 +0800 Message-Id: <20190624092326.298695374@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@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 @@ -190,6 +190,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 @@ -1276,6 +1276,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; }