From nobody Sat Jun 20 19:58:10 2026 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FBE738A299 for ; Fri, 10 Apr 2026 10:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775817767; cv=none; b=qlb687W1XyFsH0teKlD0MY/z1z4MKjCQbSh/Nbyr7FIEdnVM/8j0Ga/3HgHULj3LgKqh9CnfDGCcnqfBjczG0ksvSNjeTsJto81I45+fJDV+4Hih8OBmMA87T+GwdOc7PNHra/gfM2x0DtckkTbaTMvNfeTq0BCxmvoAYAqmzEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775817767; c=relaxed/simple; bh=x3vbm8dzITfs2TJ7MgGNykoYMSBX/YyGWE+qZBJOPho=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K2QHEQyRD59RWjwMYXSQ1F8cn2v/mlGUoVRqRWpTsnfvgLe4Wjye0+TRvMcUytDMyKv8MoLMxzQu2Y/XtfDcc078y7QIYHKntHm/0TwJetdEihOjhRAwag0s7ttn7M0iwNrpTjITKdpuVK3HninAoNuiLqaG1d5up/EGLbcU9aE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=insXvcVY; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="insXvcVY" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-35da8d037a5so964992a91.0 for ; Fri, 10 Apr 2026 03:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775817765; x=1776422565; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HeexHBGM6m9iUjQldRYMFqUMdoXfHrQClpu5bKv1pA4=; b=insXvcVYKRL6+QbkbRXxESj+dwhtPvJwU64C3bOpPf1dWTUWSZHKFMYZ6VPy54spnZ +bq7lT1cDJxR/B0bxnfjpXK8UQbMlQ50OMNZ08XWJPicj7QY4rgEOUj0dR+zjnS//b51 wb4lAVHa7DYj+5v4To59Vw0dc6g1UvWzmIDk8IctoRly4ILcGITM45EobvNkAq73PlCT oetZ0oDsabICoejbXlgTND1rWiy1am/NY9beYvMTl4LtIKvyA6oJ4ZV8RgAapQu5AWWO BGW4wZYnTuZH+WNv/IwvHr9+PgHX2X3fYgS7lhWgkw0BXQq7SQYQ0gdbnODPQnEz082D qplw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775817765; x=1776422565; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HeexHBGM6m9iUjQldRYMFqUMdoXfHrQClpu5bKv1pA4=; b=NFS+4P7WNTY8bftYuMzIwb4v/aN/8WIiDbqoJhIXhfyAkIEoojrdIYJAVszR6h6sLE GUbQpK1t2CVwlL4fJedfA1yVS1U0nvbx+ff0ungLHWjmsd8KvqE++dP6TAKNGrDjihAY 2jzNmIdKzlQjpCQZu4aQW6PEb58YJ/KStv1IQmKAYwUma7baAT6c7LO6MFiBuTefaXYQ MsiWSpA/0Rg/MzrYO8Aw/N4SJuSFMA37wD9+ld0uqykh6oj45GILPIW/5oAdIfpIZGLf 7KmmlaZJ7hxTuAhCd0PrWBQ9muThcaKKmsqIt7Lq5eXTy2565Tonvnt3GOVR1PDt6D1x 2oXg== X-Forwarded-Encrypted: i=1; AJvYcCWkzzxTnzLjmuWElgEebLUHyk5uilcndA7JqFJaBL9lfn4UWvINCbrget+SDlh/DQulPkUgHwH+PrQmCRE=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2BOYcH76kB0f5NPO6I/vyLAAeMv3CZe2Ty4YEDOhUy2RNAmW7 i5tvg7z6CsGcrHSxyxg5eskk6t4tNorG9e58S10WGCp+GATgZESK9LbWSFq3MQ== X-Gm-Gg: AeBDieu29ykG28knPNTvdjIV4qNcnBxiQVO7Jdgsuv+nbpO8CmsfU/uD0zbpw1bdbml lSvNfvOpFg8IUaz3DqyMtPkXzTgRu/peyGuyAzxPSS/xuC6JVjthkPKIyFd6WWLv3/Y9NbJYwfd GCA1MOHV7XIfywMztmxr1ADCMbYobmdjwycRGA/OePD2g+dqpjQuHcjdauSSORofCkB5IDCbRaG 3BYhdFYyi9GOLcH2MJ1XKbpsXT86Q4SU7Kr8NkwrZ0XMlicFtqmN9Fk7X6JmxRtzzWDs/iTiT1/ xrnUa52CTDrWbUgCcAlceX7TNs1fZIoh3uWH4b0x7rwKIJh4Fo+FaZSEWnNtBM56Q3SDN3RDCFJ 0fYsSS8OvTwuRhjnlJLiBIR/B/Bk2+tfjNIiUY35vYuyI4IL5BcK9hxmBdNqogMo2ItVZEAG874 xjcF1Sn7oDnqHJcUe2ZuGtcpMtdKFGJKWQLq2IHKVZZuA6Ido= X-Received: by 2002:a17:90b:4c8e:b0:35b:9ab6:1d4a with SMTP id 98e67ed59e1d1-35e4280ebc7mr2927325a91.18.1775817764639; Fri, 10 Apr 2026 03:42:44 -0700 (PDT) Received: from fedora ([61.74.238.173]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35e412233ddsm2904247a91.5.2026.04.10.03.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 03:42:44 -0700 (PDT) From: SeungJu Cheon To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, luiz.dentz@gmail.com, johan.hedberg@intel.com, linux-kernel@vger.kernel.org, me@brighamcampbell.com, shuah@kernel.org, linux-kernel-mentees@lists.linux.dev, SeungJu Cheon Subject: [PATCH] Bluetooth: hci_event: reject incoming conn request when MASTER conn exists Date: Fri, 10 Apr 2026 19:42:22 +0900 Message-ID: <20260410104222.537901-1-suunj1331@gmail.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hci_conn_request_evt() reuses an existing connection without checking its role. When the existing connection has the MASTER role (outgoing connection in progress), conn->state is incorrectly overwritten from BT_CONNECTED or BT_OPEN to BT_CONNECT, causing state machine corruption. This can lead to use-after-free or state confusion when the connection is later disconnected. The issue was observed during VHCI testing: Thread 1: Local connect() -> conn created (role=3DMASTER, state=3DBT_OPEN) Thread 2: Remote Connection Request received -> hci_conn_hash_lookup_ba() finds existing MASTER conn -> conn->state overwritten to BT_CONNECT (no role check!) Fix by rejecting incoming connection requests when a MASTER connection to the same address already exists. Fixes: 70c464256310 ("Bluetooth: Refactor connection request handling") Signed-off-by: SeungJu Cheon --- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 286529d2e554..3d34cf2e5067 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3327,6 +3327,12 @@ static void hci_conn_request_evt(struct hci_dev *hde= v, void *data, bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); goto unlock; } + } else if (conn->role =3D=3D HCI_ROLE_MASTER) { + /* Reject incoming request when outgoing connection to + * the same device is already in progress. + */ + hci_reject_conn(hdev, &ev->bdaddr); + goto unlock; } =20 memcpy(conn->dev_class, ev->dev_class, 3); --=20 2.52.0