Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp144752ybz; Wed, 15 Apr 2020 06:09:37 -0700 (PDT) X-Google-Smtp-Source: APiQypLh5RMyc3uPm9XThXkK4kPVtpVtQDZgrElKOR2Q9OLqofgvHOrBAYhuLd86DPz891kMmH8P X-Received: by 2002:a17:906:1251:: with SMTP id u17mr4766669eja.315.1586956177172; Wed, 15 Apr 2020 06:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586956177; cv=none; d=google.com; s=arc-20160816; b=EElB2vzPy8QL24HqxK67TgTaEBn6Un7EjkVvPTGpAkSLlvmNO9yezYwXrIM4X990Ts D/pKhlYr3ZZgb2QmmBfCSbaTBj3F0ba7EIYhcoWeQdi6NavUp8/lT2Ts/4tH7e6Bto/u 5WgVhWqFrz8kftP1PxHPjz++t7w3WGBK1atmLl9VoyoVLI9AxSw9gWRkDz5El8wgUd8Y 611zrrL6NrN3uPnhdWemn15rb+45W/SAwfKW4kEHEDsrpSKAiRRY2h4VYMjIf7+OQtn4 RiDJJGRbtIrgHpkQ1YhReTREGYoGMHJAXSitwJbwYDa1XDKqHif9SayEAiX6SHb5/s9/ i4ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=vIh5eTB8uOZv+p6Eoz7dTqGKo5Rnh4f9sFKMcqBFlS8=; b=sFnCQSo3MZl3OBC/iOWhnZuUgPjyU5b2jHnvM4ZImdmxDpVamQuS5mPSa7koVns1Am fszzqbcpL3ssrBE0iTk9UcJUJJX/0T4nchyWKyYNt7DYrx6dCelnr50X+xGDogaMvx01 JuyOy2/Npjfc/n0NL36x6BhERN9NxTeFsy++HRdBV9p8joQ7jZmPTMzFAXHkojMWTZtY r9lBxzfapSJuPoCDeP+2GwIiNC+n8L8ESt4Y3bsc5mgcZG/dMjj+K+B1f2N4YOn9CGQQ cEtFLdDECwrgWvirZIWbpLRLmf1i+mhxRsa6efxDN0SKC5cNFC4E22SrL0pdO7nkC49V vJqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TKSsICsF; spf=pass (google.com: best guess record for 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 y1si11673477edp.606.2020.04.15.06.09.05; Wed, 15 Apr 2020 06:09:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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=TKSsICsF; spf=pass (google.com: best guess record for 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 S2504545AbgDNS7N (ORCPT + 99 others); Tue, 14 Apr 2020 14:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2504542AbgDNS7H (ORCPT ); Tue, 14 Apr 2020 14:59:07 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7230C061A0C for ; Tue, 14 Apr 2020 11:59:05 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id o22so9690707pjp.0 for ; Tue, 14 Apr 2020 11:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=vIh5eTB8uOZv+p6Eoz7dTqGKo5Rnh4f9sFKMcqBFlS8=; b=TKSsICsFBab9k1r/Gi5jGrU9d5rCvU8AKwKC4tWt+X4MHt8DCtd7JylXyPtfDr97It cWvrhcw8k895UD38eusJiJiXLt8LJcVf5Z0GTMQSaGZKkNGuX6QUnhfCUraiApk4aPVC zUkxuEaZUfBnb4dgp4Wh8RldstNeGPXqBLEoFg8r+Q29SKYCDPNTewavGBOmD/z5ndit sA0PM1rjsRpW6QeqWDeMcUTlWpnOqsT5kP59nabvANNNLjPhqSj+/KRdaXN56Hkl3e7x CBNpY6OGBXo+MK5RU/QXKqUxCMUGcDACNLYg8lKP/HdrZAgGjKO8EUe2ZDtvBqYc5LoE rfTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=vIh5eTB8uOZv+p6Eoz7dTqGKo5Rnh4f9sFKMcqBFlS8=; b=ZDBQHV5PxqYvS5+V6IOV5RcU63uiFvpwdhHAEl0zBp/+GRQ4NfW3JWg7akCD5bp0rx 8f22vs5rAIOd3rPuSTJf0t7hqvV4ArjtY8L8pIdJe4Nm+10peWPB0W26zrmOhDF7765v 7/G6Leje62eBdspHRdacling8/fleP2qFsxbuXxejO4dWC3W7G+nY0KBVApf/cPjN02m dwSOhLs52OBFR6RmxIDlUGOnLsyEAqNuMQVDPtZCHZBCZK3JC/54OVFuc5lBS/SDxhXP LFWBVyRsrD4LFmZ+6RTQjpBxRQDJ7WnLrB7LE5uOqpMaYgLHhSc2OauJfcywSCQfj7kC WXfA== X-Gm-Message-State: AGi0PuYgbYbz/bead/Wj6Jrhv98ycpOwN8tggWenhwS+NPXK5kJNNhW1 fLOzzMZD99PJyztrbXHb7GbMpgmzNovC5w== X-Received: by 2002:a17:90a:e02:: with SMTP id v2mr1764972pje.131.1586890745234; Tue, 14 Apr 2020 11:59:05 -0700 (PDT) Date: Tue, 14 Apr 2020 11:58:21 -0700 Message-Id: <20200414115512.1.I9dd050ead919f2cc3ef83d4e866de537c7799cf3@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.0.110.g2183baf09c-goog Subject: [PATCH] Bluetooth: Terminate the link if pairing is cancelled From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud , Manish Mandlik , "David S. Miller" , Johan Hedberg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org If user decides to cancel ongoing pairing process (e.g. by clicking the cancel button on the pairing/passkey window), abort any ongoing pairing and then terminate the link. Signed-off-by: Manish Mandlik --- Hello Linux-Bluetooth, This patch aborts any ongoing pairing and then terminates the link by calling hci_abort_conn() in cancel_pair_device() function. However, I'm not very sure if hci_abort_conn() should be called here in cancel_pair_device() or in smp for example to terminate the link after it had sent the pairing failed PDU. Please share your thoughts on this. Thanks and regards, Manish. net/bluetooth/mgmt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 6552003a170eb..1aaa44282af4f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3030,6 +3030,18 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data, err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0, addr, sizeof(*addr)); + + /* Since user doesn't want to proceed with the connection, + * abort any ongoing pairing and then terminate the link. + */ + if (addr->type == BDADDR_BREDR) + hci_remove_link_key(hdev, &addr->bdaddr); + else + smp_cancel_and_remove_pairing(hdev, &addr->bdaddr, + le_addr_type(addr->type)); + + hci_abort_conn(conn, HCI_ERROR_REMOTE_USER_TERM); + unlock: hci_dev_unlock(hdev); return err; -- 2.26.0.110.g2183baf09c-goog