Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp689627pxk; Thu, 24 Sep 2020 16:18:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjz0YOFaDXF0P44/1b0bWnSvA+ol64OgJYSJzDTNNVR9Zi5MbXez7IHxAXAxaq9IxAbDNF X-Received: by 2002:aa7:c693:: with SMTP id n19mr1148500edq.101.1600989508289; Thu, 24 Sep 2020 16:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600989508; cv=none; d=google.com; s=arc-20160816; b=WcTi7X+aobZm0EI1OwVq1NY1/HICuMPS8458DcWTpJkH47WNZBEpEqaIywGaXh6ata XA7MY6MfIgh8rWbSLZJbHaZsWjZmLj9Fv6oxKyJpST+lD9yUwHWsdMxMJIkqkogMaVVm 5Ty0dd8iXptJBhAxp7pw2p1U6B3qLLzkKP3cvgsEzyqy9Box8TINdYFST9h58MNtYO26 Q1elvBEm3ftfT5TcnB7zPkwaPAfnTHCHx6QSAdplz1hCrDtU2n6L0GVHLLYk/UqMy04Q RHBRyhXi38xy5dRWLVo8d6lC2MYksGnQ3ZxEwwBQSc8HpWsOqZWdkDMFEtoarHnSe1rb NroA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=BRLWzw5KfOjJw5AE9R3gLTg9imcZgd5TO4r9CcaoPCQ=; b=VxPxfj+f7a4sRc/amNcnIg1DKUDm/PN72x1R0KaTkUwpPQHE2WaqE3kVPeql4M1mWt WsIq1bI5yWN5RvUWIOYr8Ud8BjPxYHrEC+085kAS4eZdnV2ytqTyvgI/TLGdyhZFwoTb M0Q+xJq4lOn5MdmEODdOPw2UdJGb6uAVQsOIMj8daTg0WS/XvrIJposvxpwe0Uyv93Fw D84hZLtV9jDb5goEOam5K9blfTgDR2Sh+I1ZvKB2tSGrQuvHOAYzaiEu2MZssUiQKBke 1+9M2fkoKxkBhBTGr9U0kf6ZC6w2UKSTGrzuO+pHWmOK0BuaLuNzmCa38MD+GteQuyuc bMBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CDxNFsbu; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp1si828874ejc.307.2020.09.24.16.17.48; Thu, 24 Sep 2020 16:18:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CDxNFsbu; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726662AbgIXXRs (ORCPT + 99 others); Thu, 24 Sep 2020 19:17:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgIXXRr (ORCPT ); Thu, 24 Sep 2020 19:17:47 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DFD0C0613CE for ; Thu, 24 Sep 2020 16:17:47 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id i17so495314qvj.22 for ; Thu, 24 Sep 2020 16:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=BRLWzw5KfOjJw5AE9R3gLTg9imcZgd5TO4r9CcaoPCQ=; b=CDxNFsbuqgptnC5RyTR8/pA7twNx/mawY/cqEq85M671xbEzmEQjL+hMUUbxHMyvfg bknEpjXZFP+cLCkJLfOteUWt9AzDoHdegXvs66lumwId1zeb/HctNf6+wixOOHkw571q Ad2Kf/WYrTCSsztAo+QfM52UZl36c4MO8gG2VdJY6PkNAbuAWYD29+q1T2jCGk54ETnJ 6a+zdkLA8qIBLtf84nGuIFL/+KOSGyX7EBy7UmVapLS4NOOxRdcYhYTShYxVuLJ6FZav 5plQxBL8dBmAWyiFfDvWoCf60nbl+UWsGCorwGCyEjeuKKOAjswrkUM2H77x70KAjO+9 pfvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=BRLWzw5KfOjJw5AE9R3gLTg9imcZgd5TO4r9CcaoPCQ=; b=udtO8FQ6xhrLZh2L9R29j/wE4AIlljGxY3yO8bAUjn3A9ZwZ/ncDBwFWn2b6dbhPqi GsSpLOJiuCljThm7N5amiJwusr2OOiuFW1y1jgvcTZJL5redVWn7lrdcnNeRwaEKcjYy qf/GyAfx9civwz8IcBFoND92uIFdjEASIbYntG0H1/8+bfsShe9A5kxx54WNGMfsS4Dz 5ov6CVNEa84HLAZVLiHZE/jYUQGn5r18L4TBXjVFnGjlol2aYwUBQHDUKkWwM4ZeOaOO 7Xch0EG5YlFfzL/8oHAcL/M0luLaubwR9Fq5asd+jBYXW7srHVuvn72wZtkNK0GBrBUA MNXg== X-Gm-Message-State: AOAM530Vy6NQa5JMBvqxRTNi4PYDIBHm376a69Oh8a0YZ1mA9UxkMzST IdgLN+HzkzpwBsIFKzchOCt+xqh9jCp2c9ZIlVRVKU9Q1lgGOfLAG75L8RzZCGGQGfUcrHtlt4y ml18oXltfSUQEdheiW/HI3129BRjb77FEUw+DxjnWrlPq02SmtulM0yIcyQnoe3gpeEENjDly6a 4q Sender: "yudiliu via sendgmr" X-Received: from yudiliu.mtv.corp.google.com ([2620:15c:202:201:8edc:d4ff:fe53:2823]) (user=yudiliu job=sendgmr) by 2002:a0c:a482:: with SMTP id x2mr1631875qvx.56.1600989466672; Thu, 24 Sep 2020 16:17:46 -0700 (PDT) Date: Thu, 24 Sep 2020 16:17:42 -0700 Message-Id: <20200924161730.Bluez.v2.1.Iedecbb8c8ebb111b14206dddc5bea3c40dfa1771@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [Bluez PATCH v2] device: Disable auto connect for temporary devices From: Yu Liu To: linux-bluetooth@vger.kernel.org Cc: Yu Liu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When connecting a LE keyboard, if the user input the wrong passkey, the stack would keep auto connect and thus allow the user to retry the passkey indefinitely which is a security concern. This fix would disallow the auto connect if the authentication failed. --- Changes in v2: - Move the logic into btd_device_set_temporary Changes in v1: - Initial change src/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index a4b5968d4..13159d927 100644 --- a/src/device.c +++ b/src/device.c @@ -5684,6 +5684,10 @@ void btd_device_set_temporary(struct btd_device *device, bool temporary) if (device->bredr) adapter_whitelist_remove(device->adapter, device); adapter_connect_list_remove(device->adapter, device); + if (device->auto_connect) { + device->disable_auto_connect = TRUE; + device_set_auto_connect(device, FALSE); + } device->temporary_timer = g_timeout_add_seconds(main_opts.tmpto, device_disappeared, device); @@ -6036,8 +6040,9 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, * treated as a newly discovered device. */ if (!device_is_paired(device, bdaddr_type) && - !device_is_trusted(device)) + !device_is_trusted(device)) { btd_device_set_temporary(device, true); + } device_bonding_failed(device, status); return; -- 2.28.0.681.g6f77f65b4e-goog