Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp267520ybv; Tue, 18 Feb 2020 22:46:07 -0800 (PST) X-Google-Smtp-Source: APXvYqzWUHeRXK0mIBVZ7m2FqfbNd/rfdKZ50kLmynEVCMlwUJjVyPF+OybLYt0Kssp6Ckng2et3 X-Received: by 2002:a05:6808:7dd:: with SMTP id f29mr3790591oij.67.1582094767128; Tue, 18 Feb 2020 22:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582094767; cv=none; d=google.com; s=arc-20160816; b=RxZhKMTIsiISPmEaTUO/3Z+7jgt5Ubm2hr/yh3hvHNj6b+DneGv13W1X6OxW1yw3g0 /5Gx6xilnVUDCvlBP5Nr3Q6NWbRdTtVWxghY46TNBvLp5Sk/c8UJ/gQx2WggYMysuNJi /s7Pthz/bxmf0o/0/o+p63F2bcQ020gwuMczTLOkyPHq+qOOG2B8u8/W/7HVmT4iTMmB 0Qu8y+ENFYntcPKNAdPA/mxCOai+JGNEFCzsvz3LxtwLxo72eaw0vKQartJeq9noS7S5 S0TA8DbKY34vlH250CRmJ4hsypaWeZKcmK4pCMMlf4IGyMe+D1RTdqCrEV9M+RwPnMgC 6kyw== 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=JFI3+kM1LWruGVLKeVPFO/XZwyOSYT/vDPiEnVdBj2U=; b=MegOSM6YOmeT+Dzg4EGmNJrGaYb0KQn0MkoCqtLeu+KYqFq/aaWrzZN6VWqxu4m1wl vdF4psRkeBDJe01Cx3Nblqqpi5izyKAbr3/zKald9kGnub4XPw5OZ1v5Q49J1nliQOgD YHTRyPUZce4deoorwvXTT1JJkpq7BsuYpZvx6hCUDPWzYxTpmbt/9WZQ+mF/TsFY5D6P fX0yMWbhAVb9TVhGl7VC4MEd43aRgjPuHiD7rcFc52ekarPpbFpKT+HFVe+I6jRh4tz9 +fVe3Lzl9z9UhQ8OoqgqKuwoO9uyQgHgSD+1VcgSmh6qkvzcDnuZk64ghDhrwrVVR8Cb 7mNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PnuQ7Svk; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v13si664205otp.273.2020.02.18.22.45.35; Tue, 18 Feb 2020 22:46:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-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=@google.com header.s=20161025 header.b=PnuQ7Svk; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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 S1726528AbgBSGp2 (ORCPT + 99 others); Wed, 19 Feb 2020 01:45:28 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:41968 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgBSGp1 (ORCPT ); Wed, 19 Feb 2020 01:45:27 -0500 Received: by mail-pl1-f201.google.com with SMTP id p19so11585402plr.8 for ; Tue, 18 Feb 2020 22:45:26 -0800 (PST) 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=JFI3+kM1LWruGVLKeVPFO/XZwyOSYT/vDPiEnVdBj2U=; b=PnuQ7SvkJrwFsCkOr3rvHKfrDrwUoHQwrQQitEv/ezWelIifCVoD7E3e/i+/2TbM+X IwDtLxTnUEfVdwcl86OnwvXOLU70wOEw5HjL0v/xxm5717Pb45kjxTcUhUMbrmdsyP+C SBKE6mym4PF3P72mIY7hikh8i3a0aESWh+EGXRwooJhSJ8OYdGDoz+hXpRSaw0axM8Ex lC+0iV0uJuKu1tSimojwsqaUaYK/Ci5C2h9tZDxNlL3m1P3aB2xekQ91IYnZXgMP5WR2 +0hlJJr0F5xYVtjxQjNN5VJvD2bkr1IH8Z41iOCRcsbF8sY6i5hUm+rC3ZHfqAgUC51h Ua+A== 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=JFI3+kM1LWruGVLKeVPFO/XZwyOSYT/vDPiEnVdBj2U=; b=CgX3EHQUiML1HFQdxxqWzj7g7gf/IAqT4kMVgsYFVaCRg4G0xllFQThKh+kNTOvQ1V JZLaUyK4uDhHougB7U5VJ0Z2nXJoipSXuM6hC4MBz3RAMg72Al+MBtAtSYIs8BwZ8FNh KXpztF8ON87sCT0jP/EhlUDZooXjLIaBjFJoA1Dkc7skGnf959dKHuETHENZ221cbjdf nEDJL7Q8enZk1FHXE/aadGlijtXyi0RVQyzzQK3z9OsJdEzVozC6n0URpdJApq5UT03o sSL9tTJrH4YdkAJcW9U+H0mjz5Xg1tLCNx+jO4633IX5CAStxo6e/4kiITKAuNqgQQ04 6C1g== X-Gm-Message-State: APjAAAWLDkk/sjfz8qmOPyPHeB8/VsnQEVV+CzF3Zq7PsZXqiSJajvux oEXOE3PqCbqqVDhcMhVIwN4aPpT70wyPWGJh7N5NRuZI6XrSL2Z75NoBZqkTtfuW8UG8fa/P/xx BtfE9aMDo5XZIfSls0utySNs+dgB3yxgqtFQVq5+W35n2SBQ9sQirno6qyUy71lezkvgUKmQUJQ qqX4Q4WOKE+bI= X-Received: by 2002:a63:5443:: with SMTP id e3mr20602878pgm.245.1582094725566; Tue, 18 Feb 2020 22:45:25 -0800 (PST) Date: Wed, 19 Feb 2020 14:45:19 +0800 Message-Id: <20200219144442.Bluez.v2.1.I145f6c5bbf2437a6f6afc28d3db2b876c034c2d8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [Bluez PATCH v2] bluetooth: fix passkey uninitialized when used From: Howard Chung To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung , "David S. Miller" , Johan Hedberg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski , clang-built-linux@googlegroups.com 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 This issue cause a warning here https://groups.google.com/forum/#!topic/clang-built-linux/kyRKCjRsGoU Signed-off-by: Howard Chung --- Changes in v2: - refactor code net/bluetooth/smp.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 50e0ac692ec4..929e0bebaf80 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -2115,7 +2115,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) struct l2cap_chan *chan = conn->smp; struct smp_chan *smp = chan->data; struct hci_conn *hcon = conn->hcon; - u8 *pkax, *pkbx, *na, *nb; + u8 *pkax, *pkbx, *na, *nb, confirm_hint; u32 passkey; int err; @@ -2179,13 +2179,12 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) */ if (hci_find_ltk(hcon->hdev, &hcon->dst, hcon->dst_type, hcon->role)) { - err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, - hcon->type, - hcon->dst_type, - passkey, 1); - if (err) - return SMP_UNSPECIFIED; - set_bit(SMP_FLAG_WAIT_USER, &smp->flags); + /* Set passkey to 0. The value can be any number since + * it'll be ignored anyway. + */ + passkey = 0; + confirm_hint = 1; + goto confirm; } } @@ -2206,9 +2205,11 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey); if (err) return SMP_UNSPECIFIED; + confirm_hint = 0; +confirm: err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type, - hcon->dst_type, passkey, 0); + hcon->dst_type, passkey, confirm_hint); if (err) return SMP_UNSPECIFIED; -- 2.25.0.265.gbab2e86ba0-goog