Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4139093rdb; Mon, 11 Dec 2023 09:53:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFw+qqSODngQ99LyU0UEABv4C54IdrarfLM/j5KeamlGZEUH/lwPb1mkWCmeVVlZ3L/MMeQ X-Received: by 2002:a17:90a:a40c:b0:286:8f8f:5e38 with SMTP id y12-20020a17090aa40c00b002868f8f5e38mr4290003pjp.11.1702317205692; Mon, 11 Dec 2023 09:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702317205; cv=none; d=google.com; s=arc-20160816; b=bPooYRhczJwJx78qIBtuHtv0WmIfgUhrd+bWsC/mbwf9B5Gw3xqKnf9uhV/NAdWgtT O85RFJ6kwErGGwM5uIGr3KSADmGI5cNbLthnwN02YWOQYLiDt7W+FOZIa/3bgVV0NGIm 3RviCq40Dg8+K6Fcu8LXe5sXHZhKR7jIxhL5u1vfYFF89e4r0YzKbNv48s3SIxIz5EuL +MslWv43g9Up1/wK1E5M4kOGNCYfiZDyrHzQNDZHoT1fG7caxFt/4ZsWhxaHLrgwYkT9 eISw/HRXj9EfpAzCMi+8yRkYnRgEyZTd/vQ+nopa1bYjFptJTalcE4KCy3Tl66npnXl5 2WAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=i3ufnXGidcOnmQQt6XNrIUZLzoxqF+duuoKjMVgCFx0=; fh=vXt6YC/PELIn7atjm0/yx5K1n1DXl2fZg+GiyUdTSiE=; b=dDY4yB3AMVDfAlNCGg7Nx3GfLfBBIctcHduHgojk8hqOQgr3/5FgIEKxISeoHcXI8U FBYkH9Nv0zyPoV5tpuRklZs4V/TkEx757m83dwuOPNoBHq8Uy0r/z2AKpoHZRHBdpzI1 7f+FSlSWPVKoQflPQ/MID25VHlUqWMIsLTkk0bYDGSLyVEM48AwJJASa8asU9QsuycxP Cxn6lwSfF6CMeFbw0w0ZvEF1g/zllLCZssGHNcwu0xV5Oqir/N82LqY0EejT5yiZQQ5E bPPKNHu8BdnAXwIvLsNwi0guVVx+rui8zjNBfkACYmbtfAPTKwgPdD5sgT4WMBZ+FTCq AS8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W6V2EUf3; spf=pass (google.com: domain of linux-bluetooth+bounces-528-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gx6-20020a17090b124600b0028a1ee84596si6454056pjb.186.2023.12.11.09.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 09:53:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-528-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W6V2EUf3; spf=pass (google.com: domain of linux-bluetooth+bounces-528-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1C68128194A for ; Mon, 11 Dec 2023 17:53:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 382944EB4D; Mon, 11 Dec 2023 17:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W6V2EUf3" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88BBA1723 for ; Mon, 11 Dec 2023 09:53:00 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c9ea37ac87so65555461fa.3 for ; Mon, 11 Dec 2023 09:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702317178; x=1702921978; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=i3ufnXGidcOnmQQt6XNrIUZLzoxqF+duuoKjMVgCFx0=; b=W6V2EUf3xek/kbKi26Wrx1JCWBuYDQux5Imrx+JOoyBpCPLuSjW+YR3TGi+9TkvGHc so4oKD0GuTChQkNgsxs+muLFecohfME12x/AZssUmgvcv38lWT3A0GxtkTrHUIhhbHvA jJhA/7AMymp4Sttl/q6vJVPkrKeAzux86XpA9GWVVjVxSxwTynIhIGTDvd4aOTGUD7Bb VKpnJOx7GACu4BXvUhfCnlFDA1puyq3Ec00en28eKqXcF4vw6ASD14n415dbY0AhTCr5 X9b4vMeXpocB6ywMsrbJJhUsMCrqAW7B/HTIJOyh0Kw/4m8BATuIytJ3fZNJv0M7ErjL +5+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702317178; x=1702921978; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i3ufnXGidcOnmQQt6XNrIUZLzoxqF+duuoKjMVgCFx0=; b=ecTPCyK008x7uE0p15RRBZGHmdxhtvTPh9gHm7AyUc2cruk6Vm11KnS9qqgZUveX9H latu6EXZIPQA+scuj8TeKd20gvQ/vOLnPq9VWgEougpSf1ubsETg8XrQu4+grGnf9xoG OYXr9IkIICoELuq3MW8OYBDjm5uor/tdRtjI4w8lYiJcie68QQhNowGN5hGWvc31fu0X 4FDm7GOtqpX1BWQBcWfp+hpmLHAHSFPRMc5I8ntoTWBFZDr14DTByNmnalhdynyGULp6 rz7nudrDTA7uFVNwibsBo2G+Qn/jXav7wX6E5DE8NnH6Sr/RKMO/rCahtp04n+N39o+5 6rGw== X-Gm-Message-State: AOJu0YyUziawUlrgUhSDmIJPwXfBFbpzKykwYs2swW8rvI6kwu9bsVXs q50vEUuGLhcAKsNk3zch9yNFoNO7p3MvMwxizbNuELZHk+8= X-Received: by 2002:a2e:ab18:0:b0:2cc:1e99:3f50 with SMTP id ce24-20020a2eab18000000b002cc1e993f50mr1845995ljb.43.1702317177712; Mon, 11 Dec 2023 09:52:57 -0800 (PST) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <6576dd12.170a0220.262f6.400c@mx.google.com> In-Reply-To: <6576dd12.170a0220.262f6.400c@mx.google.com> From: Luiz Augusto von Dentz Date: Mon, 11 Dec 2023 12:52:45 -0500 Message-ID: Subject: Re: [v2] Bluetooth: Add more enc key size check To: linux-bluetooth@vger.kernel.org Cc: alex_lu@realsil.com.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Alex, On Mon, Dec 11, 2023 at 4:57=E2=80=AFAM wrote: > > This is automated email and please do not reply to this email! > > Dear submitter, > > Thank you for submitting the patches to the linux bluetooth mailing list. > This is a CI test results with your patch series: > PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=3D808= 718 > > ---Test result--- > > Test Summary: > CheckPatch PASS 0.48 seconds > GitLint PASS 0.21 seconds > SubjectPrefix PASS 0.07 seconds > BuildKernel PASS 27.52 seconds > CheckAllWarning PASS 30.74 seconds > CheckSparse PASS 36.91 seconds > CheckSmatch PASS 99.35 seconds > BuildKernel32 PASS 27.19 seconds > TestRunnerSetup PASS 430.58 seconds > TestRunner_l2cap-tester PASS 24.23 seconds > TestRunner_iso-tester PASS 45.04 seconds > TestRunner_bnep-tester PASS 7.09 seconds > TestRunner_mgmt-tester PASS 160.98 seconds > TestRunner_rfcomm-tester PASS 11.03 seconds > TestRunner_sco-tester PASS 14.59 seconds > TestRunner_ioctl-tester PASS 12.19 seconds > TestRunner_mesh-tester PASS 8.72 seconds > TestRunner_smp-tester PASS 9.77 seconds > TestRunner_userchan-tester PASS 7.32 seconds > IncrementalBuild PASS 25.72 seconds > How about doing the following: diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2ad7b9f86f74..f9a8fb9fcce2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -750,9 +750,12 @@ static u8 hci_cc_read_enc_key_size(struct hci_dev *hdev, void *data, } else { conn->enc_key_size =3D rp->key_size; status =3D 0; + + if (conn->enc_key_size < hdev->min_enc_key_size) + status =3D HCI_ERROR_AUTH_FAILURE; } - hci_encrypt_cfm(conn, 0); + hci_encrypt_cfm(conn, status); done: hci_dev_unlock(hdev); That way we don't have to proliferate the checks over to L2CAP, etc, so we consider that the encryption itself fails if the conn->enc_key_size < hdev->min_enc_key_size. > > --- > Regards, > Linux Bluetooth > --=20 Luiz Augusto von Dentz