From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 D22B631197B for ; Fri, 10 Apr 2026 17:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775842498; cv=none; b=cgA526z6xkTN/Hvh0jeJhiA0P/Pdf4sGA571iLbiLzqC+V+0ZWbLjdZJjukJtLQKT0fnTr3lvF9GkBEM6ZUDUmuGt6LVWQLxrcjst6q1UGdBCsm6CRh7Df8vducunRZ4jjLVgpONWh5bhkf5NCQParj4daSY59VhpFK/s15sBbA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775842498; c=relaxed/simple; bh=DYw7oNNqEGz4ESlBhGL7OiIoItzBIY1f9AUIG+wjyw8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=b6rB86u0kp0PKN77ATLhNdwrBea2YTxdaYb+59mQ7C3QTutYSj8e7wCYPtJYgmkTar+/uHN7ROS7vCQLf/WZVAbhmjzPAnPXLSLHoby3MsQZYxjiCxEVYS27kIkaH4c9CPIWsH0wsFvJL6xFEbMnBuNINYrBXPb1wH7c5G2nhdk= 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=Qlrp1ZP8; arc=none smtp.client-ip=209.85.221.51 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="Qlrp1ZP8" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-43cfd832155so1490449f8f.1 for ; Fri, 10 Apr 2026 10:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775842495; x=1776447295; 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=/pLuXGk4XEx5958UjMrbFYUUsyqqJwTgYTzxJrMDu/k=; b=Qlrp1ZP87eQvFJUtSeKn0aBF76hRL/Wg6vLuntEvoQZ4IOpH5aFSSwxtEfzCyr/nFi /8aVSMunWwTOrwNDyDJ/PiNfnoN8uPRo2Qs+7z9qZm4/yFi08GuiMfUTyD0TzPGwufuv UIZVDUy9vftJkJlkKZsg0tUCnfu/AwdEaQXRS0gToUF/yXN2qAuhYOoMdbNzknz1kDtg Yy+DVd5KEX9g+HePRNRWrC2fmwN/dWiOqwL9+9j90d9/o4RJ2olSDJp88VWjubT1viOL RFgGiOus6uIbiTCEEdE+r9vXokIthR5+bdFPqFP2N9fioTedXfwO5eE/suthgfMW2tst s1Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775842495; x=1776447295; 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=/pLuXGk4XEx5958UjMrbFYUUsyqqJwTgYTzxJrMDu/k=; b=GVqwxrPyPeTZf9yuh8t3+NXhEaPoMAPRrYMxSxHcJMykegRl/t/U0iyBIw10ebLQg8 MJVxHkGvAFHEQyM6HsHyqxaUYpmLs6K6DU7Gk4o6qiRhdzdl37WxliLCz/o+Lx1PUPnp vSyl9wbNUmhEPtkT14tepYqFmrYFrutt5eVXiDiB3p1yg7FDgeZYWw7AouHeODdgCISm Qj8JnMc8xi079dpTbu+Krg/WVLVfv+xoTao+cyW/lDc3qLzh/190UmWbQYnYoaOsMH8s cEtZb4RiKepcA7SHgf7Eg/7nw4vhuVt7RUPKR1MXC5uD9EMPjcy16p3vtiTBCgzwlLoP P+yg== X-Forwarded-Encrypted: i=1; AJvYcCWWcuqoT5zIjMS7s/tXVKZHo5cmDw0c5KcbnVMfFzD/ZewWUHdGgW8/0eGOVz3NrAiUQ87mUXy7i27KXjE=@vger.kernel.org X-Gm-Message-State: AOJu0Ywl00EXvNem6vuzP4Ju8tirD81GbUI+t07dBGEy5NvOPorJc394 Tst++JekQZID3MuPcqi5247siFggtV7d7uJpVKrjqQo4fOT8oBxqaBWP X-Gm-Gg: AeBDieu1pHMZsrb4yFNcTkj0k6vvyLpHFU9veNC3SwLwBRL4tQTTXwf5C9xUTeS9AK2 8DAbL7XRsr8TK15XNdZBaCXoGLYaxbkQ0BGGMYFbMpUFHG0LY2MQFoiDdredrZoed8eGJCaQI+u qrAKsSPsaMY5laqQzmdF0e4uUfwqu+mfTej1qHrf/UUh2PbM6YeE21ubH8Vn7B8z2G+vbKK5Ml6 1ZbJNWPzuyWqcjTpLrS1vHM1Ra9Kmez8/Nww0Km75pIhp15ViLn0xP+iOkmJpe8Z0jlh7xwzyCg W2LafMfNFx6bJyNZD2FMC2DmyfFoEiocRg7hNsqB33qoFxSELk4lPWz2X+eRYTTasqV2YTrgBgp dOQXqQiIX025A0+d405Cj2A2CG4COU3G4MS8XiPH3vYauaDhO6yaqPCM8FlRz1IKwn/Otscs35V tFXnX3yxSrA09Sr6uFZG7MB7g4FmgSKHE5TIImv6Y2wr+FdyttNKpCExVS0wSgv4/OFYomaGHYZ pIHwoWgJlPH X-Received: by 2002:a05:600c:8709:b0:488:945a:ed63 with SMTP id 5b1f17b1804b1-488d6655adfmr58259555e9.0.1775842494835; Fri, 10 Apr 2026 10:34:54 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d531f229sm119327525e9.3.2026.04.10.10.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 10:34:54 -0700 (PDT) From: David Carlier To: Marcel Holtmann , Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, David Carlier , stable@vger.kernel.org Subject: [PATCH v2 net-next] Bluetooth: hci_conn: fix potential UAF in create_big_sync Date: Fri, 10 Apr 2026 18:34:51 +0100 Message-ID: <20260410173451.4797-1-devnexen@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add hci_conn_valid() check in create_big_sync() to detect stale connections before proceeding with BIG creation. Fix create_big_complete() to handle the resulting -ECANCELED error and validate the connection under hci_dev_lock() before dereferencing, following the established pattern used by create_le_conn_complete() and create_pa_complete(). Without this, create_big_complete() would unconditionally dereference the stale conn pointer on error, causing a use-after-free via hci_connect_cfm() and hci_conn_del(). Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections") Cc: stable@vger.kernel.org Signed-off-by: David Carlier --- v1 -> v2: fix create_big_complete() to handle -ECANCELED and validate conn under hci_dev_lock(), matching the pattern in create_le_conn_complete() and create_pa_complete(). v1: https://lore.kernel.org/r/20260408155638.95927-1-devnexen@gmail.com net/bluetooth/hci_conn.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 11d3ad8d2551..feebe933efc8 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -2130,6 +2130,9 @@ static int create_big_sync(struct hci_dev *hdev, void *data) u32 flags = 0; int err; + if (!hci_conn_valid(hdev, conn)) + return -ECANCELED; + if (qos->bcast.out.phys == BIT(1)) flags |= MGMT_ADV_FLAG_SEC_2M; @@ -2204,11 +2207,22 @@ static void create_big_complete(struct hci_dev *hdev, void *data, int err) bt_dev_dbg(hdev, "conn %p", conn); + if (err == -ECANCELED) + return; + + hci_dev_lock(hdev); + + if (!hci_conn_valid(hdev, conn)) + goto done; + if (err) { bt_dev_err(hdev, "Unable to create BIG: %d", err); hci_connect_cfm(conn, err); hci_conn_del(conn); } + +done: + hci_dev_unlock(hdev); } struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid, -- 2.53.0