Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp122480ybb; Fri, 27 Mar 2020 17:35:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsvgVzRgBX4YQY0Yzf/boXS5dryhpLr0OA2PZ980imycceXIlCcb5YUDSOysn5FL/XaXIE7 X-Received: by 2002:aca:5354:: with SMTP id h81mr1086057oib.164.1585355704310; Fri, 27 Mar 2020 17:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585355704; cv=none; d=google.com; s=arc-20160816; b=sFcuS9625ZbWmZ8ZdYnE+3ohVeL4SoM9z/3+u+FvNX1cIiUY8iy79OP8Ct1RmKLEUs o6CcVT+wiChYPdl4SDED5t+yAQX0TsclQVNZOGhzKEBrma38P5tqYfPYLn6G89FYo9XE 0PQi24/ktUyESRVg0SbRR3XjhhwTbWI7tjUVlTnzPfKOvmZWP3WeHZzYFgol9PtBCbmg ufeZY18epcTepTHjQ+QQ88vVPzZDWa4lHxzNXSirpy5DlPoDRDw6W+Ler31Ea9ERHBZP piiocVqRogrzzif7MqJssmxl5zS/JEwEDTep4S8KYpN/jRJzpu40IojbN5hpHCcbZLvi iwSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=UbLv58JbPZxhtNFgATo8vniurV6oOws6JszXEjaMpmE=; b=nUD9ydZGUiaeK/6dReKiKyNiHYxyoSp1cCaSxzSIKrfrJbplGCSgcTggU4GLqETrHc hDCbnXa0x6go5hEs6djPqqzWzCbc/o6aNa2jkalNmGF1yBtzmdTA2AKHYkSzzdpL/rJo JkhNgU/+T3KZ9WdRJxMAjkZukhb3uZh6GHR8mFwk82kIV1V5USM15tQsPVstzQz69aMj 72rfcV2udP8FmGehGlEuLawmJ0IX/nsCbU4Lp76+zvkVac4xjjWJ1fS7Bm4kDY9frYeg UsnkPLC274ThtKMH2KSfE5ADAV2jglJfE0pGQjhASJrd6Vyvg/QETN3PDPunzwRg4KMT WSnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CikuszFV; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l185si3100699oif.274.2020.03.27.17.34.52; Fri, 27 Mar 2020 17:35:04 -0700 (PDT) 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=@chromium.org header.s=google header.b=CikuszFV; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgC1Aes (ORCPT + 99 others); Fri, 27 Mar 2020 20:34:48 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39953 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbgC1Aes (ORCPT ); Fri, 27 Mar 2020 20:34:48 -0400 Received: by mail-pl1-f193.google.com with SMTP id h11so4101867plk.7 for ; Fri, 27 Mar 2020 17:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=UbLv58JbPZxhtNFgATo8vniurV6oOws6JszXEjaMpmE=; b=CikuszFVXSEMr2V+pG0C2CKNOoHoLbiEWQRhJjrT86g42Gpg9bK4OenhRL5mX1ef3r ZjZphmIshyuS6WwAeI2Z8pPr9LQxnqwSgFLs4/SxiCjlbPmiELMERflBTQpgsWNX4lk0 LjFVG/IzSOpOKJqaqG+RBCTYWEfvAuu28eYWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UbLv58JbPZxhtNFgATo8vniurV6oOws6JszXEjaMpmE=; b=Wi00XPTN7g4tH/YqorALzBAXHnyeV4js9feDG+cLBYkprcEdCtASAw2bE5D+Pi/OKC LoHp+dJHzZi7FRl02sb3MEIUwuoOmOin/z3dGg2Rn4I2NqqF+BpxhQf7EsB+9pjrPO3W +x+C78bDi8GMBH3oaJjpulzixZI5o9JRn61/DuqT0qAdf5YacE+kSMve2QscCqciaCIa tbfrka7Awnd8UvyMkh4YWMY91kBD0mAosDzBQlrSmmCeAzjPjoY7pSkWPQXnMhMh7jiB 30WWXz4BtGQhK0LG5jb1o8qUlyg02Oje+GMOK7C67fDTJt81flnDkPZDsLTtlWYqbDCB QCvA== X-Gm-Message-State: ANhLgQ3t1VKkAkSKxLgE3kNcclNVhisjBLK9LJ3Dxx70DiX+PIBpzvGD u2ksnbUI5oTSNLrxRw3IItcnuTFRSlc= X-Received: by 2002:a17:90a:f305:: with SMTP id ca5mr2085383pjb.75.1585355686628; Fri, 27 Mar 2020 17:34:46 -0700 (PDT) Received: from localhost.localdomain (c-73-231-41-185.hsd1.ca.comcast.net. [73.231.41.185]) by smtp.googlemail.com with ESMTPSA id l18sm1280264pgc.26.2020.03.27.17.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2020 17:34:46 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Sonny Sasaka , Sonny Sasaka Subject: [PATCH] Bluetooth: Always request for user confirmation for Just Works Date: Fri, 27 Mar 2020 17:34:23 -0700 Message-Id: <20200328003423.14079-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Sonny Sasaka To improve security, always give the user-space daemon a chance to accept or reject a Just Works pairing (LE). The daemon may decide to auto-accept based on the user's intent. Signed-off-by: Sonny Sasaka --- net/bluetooth/smp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 1476a91ce935..d0b695ee49f6 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -855,6 +855,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, struct smp_chan *smp = chan->data; u32 passkey = 0; int ret = 0; + int err; /* Initialize key for JUST WORKS */ memset(smp->tk, 0, sizeof(smp->tk)); @@ -883,9 +884,16 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) smp->method = JUST_WORKS; - /* If Just Works, Continue with Zero TK */ + /* If Just Works, Continue with Zero TK and ask user-space for + * confirmation */ if (smp->method == JUST_WORKS) { - set_bit(SMP_FLAG_TK_VALID, &smp->flags); + 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); return 0; } -- 2.17.1