Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1171438yba; Thu, 9 May 2019 11:57:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5x3uh4Wj+K9LwQczNAKHFVOD2tthUboJzLpfGFocy2n+V115CK0puieQ9C3ZYYCj62nzr X-Received: by 2002:a63:191b:: with SMTP id z27mr7808117pgl.327.1557428233329; Thu, 09 May 2019 11:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557428233; cv=none; d=google.com; s=arc-20160816; b=WPxKOKa4z5fQrVQeAGmLd1mKlb127yQNPzyxEqqr+zgb+IUM6ycFXWTUmdECFiW7M3 /Mx3iEBkS2GyEk6hOUNexDy2n243+yOdBEDTjzRi7ULuj7OfTizBG1EeqJ3KyzpHIlie L/LGwAT4vkx6PL4rc4TchPGmaN5MCCa8Lz5xO/+MtU6TQDu3Lk2M/1gE29P6b4xcFdp2 t2Bs/S5zDvNTYrlTdflm/vhN6CWTQymehw+1/zH5uvqU6dIjpbC6/eEG6ciTHHN0cKzt ozeEfLEcylv3Frj5oflhLvNHduRHYJA+VPpLR55L7im0MlHJBBy/KlCa/GqSdMaVdtm8 u2Vg== 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=0CDvG3sioSIUlpPA3AdoWpxpaVLVUYzJSztT9lTrLbDA5v8DPTj9XetpUGcg122SOL vPRpDuFgt3CFfwwhTLxYRin9EcRKfqdeA5GptiU6QQ/jqBioxpau7MLWo969sRgDYZvG KD1xPh34lCFC+KG7CRE60cyj8//UvkXkCo+CKfErTBBq/ON/3EJ3xKltNdXsxTW5CmKH QxqE0Bgvt6G+s8EkT4o19LWE+IgASKrP45Bd+u2BRwXHElvJUr1myamCkm4N3f/jm39d W2ZNJ0eUScSDwf1V2/cOxm80QwXv3+E/XgpzIrcXOLx/tH+KKWQESsCL8LyCzc1eauNy 63xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1erFEsXZ; 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 p63si4191178pfi.23.2019.05.09.11.56.56; Thu, 09 May 2019 11:57:13 -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=1erFEsXZ; 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 S1729161AbfEISzB (ORCPT + 99 others); Thu, 9 May 2019 14:55:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbfEISyz (ORCPT ); Thu, 9 May 2019 14:54:55 -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 E7346217D6; Thu, 9 May 2019 18:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557428094; bh=vXxZdof0fj3EGo3Sl0TaM9lj10tLhaQcGMTDjVs0RdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1erFEsXZUaFAH8o7ZQwNqSt2xn+zI+7En+5ATL4yMUWczGL+MNY2rcklTVsZQ6gtR he717pLsD6Fws14xpwhDQ4+U4qSE5hF6UsOQyeS+oYw95IaNTnxcMR7AfTOdO+/Pca E+QaRkugKeFAngXmMVCL5ScdNGLOTkn1/hfXoRYc= 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 23/30] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Date: Thu, 9 May 2019 20:42:55 +0200 Message-Id: <20190509181255.902104673@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190509181250.417203112@linuxfoundation.org> References: <20190509181250.417203112@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; }