From nobody Wed Apr 1 12:31:56 2026 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 C7AD936EA8C for ; Tue, 31 Mar 2026 05:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774935959; cv=none; b=Cyvlahg04ATucxcpnFQ+tJroa/XheHGn54llH0EA8iax2bmgMiCPXJr8yj61G9Fwhdwz+5Cw4M9BRxvz/pbCivYJKjZybCnYVPNQPWBOt+gEHIF66sypfSWasgfpN06zZ16Eql6fH0b/VcVRfZ0g0q+03byGRpcoJGnsJPbmmGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774935959; c=relaxed/simple; bh=IRCcHxZE5vrRcel8klWBqk+hwn76HSWyQfvZSoxQlsw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=NIPBqi/tEUqJG6Smx39b8qyBAt7/RtwSOhxvo+jySSF0dFpKYlzPx6IhsH7cBbnMNAu6vPCYKcmBApyMJGY3imA+oT2UiRrIjGneWjsopKQDL3woFwE3brcmqoGkoT/PO+28ClgsBWUaf8Y4YjaNVM+h5sL8uXGD8vm5svDh9RE= 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=L25LA1Kg; arc=none smtp.client-ip=209.85.222.177 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="L25LA1Kg" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-8d0288d24f6so406141885a.0 for ; Mon, 30 Mar 2026 22:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774935957; x=1775540757; 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=HV8dmt1HgzHPMJw/ZTQseF87igS3ZBKLE6u0ax+TN+8=; b=L25LA1KgZFafzoBVISvXENjYH1tGEg45Vgo8KxdWb3/TSEa8h5VCuaK+4RVcZt2dQC fD8hxEBkUfk84i2htg5qOQkShtKi7faKN6XpwzD4qeT+mCqZ2XIZN9MBxecvL2uyzONt O35ZyyrzsY07NHSuQqtYlH25SXw/3/0851FnBCJzAtCYTpg3tSfjKEJJE8aC7QDun1Gw fmboFpvv2woMwCRDaEf1AZK8mucyyaxMqU/osspp9kHkAdiHDnh6yv7hK70nOyfjbbtz J5ic3YKaEdbAzNJLzhS/q59o6ZXbb3GfMP2LQXf0n+ysqDox8KOTZAnu2WYZ7N3vgHJA LVSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774935957; x=1775540757; 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=HV8dmt1HgzHPMJw/ZTQseF87igS3ZBKLE6u0ax+TN+8=; b=dJq94ptQ2E8n6BwlhFvGN4AbMP/UbW343gXzjlvKDNfJ5tY/HwjnvSF0MEL7aweaWU itpqwmHTcswpQVnNNnbZ1Fg3MrflMJ2ajiIzrWSCFU0XYWhGbqkeFLd19BtGfxAAxPB/ U6x8rPyvsxgxcWNMA9n6GuG8tX3fvWUjBnKK48NqQ1FqbW0BTMpsYfYmP09E6bV39UEc xa092TLS9I9Z1UUqe/u30/WKN45p1GeHnw4tIYJjncX5TaJwd6vQtmhhggOipGG4WISb npOLRE08YdDG93YDVxjskRpIr6s2Xa1imP4kfbqT9DbJYhKo8K3cxS7w4Bz8JIJU8b+z ulww== X-Forwarded-Encrypted: i=1; AJvYcCXjTei+dXsKxbqWx+f6KJsZmp5I9my9xrjcDfAmu6qVT3P/YGbazX+HUNxQHa1u7Jhs53X7xhqyue6bS4c=@vger.kernel.org X-Gm-Message-State: AOJu0YxmKX/G4Ve4ugHq3SdulHYTexWcWdAVKpTXlUcPnqbjrGVK9bUq B5b0pTn5ukVpkj6s81bLNiGsJu3PK7Lqmk4zhU6Rp8vLnQEkUtxRegjBVNJ7YEZv9ho= X-Gm-Gg: ATEYQzys2A8quVg1clgU3TlJ6v0NCJfUa2t3RyeWjH3PrH7lYGHYyxJASJg0qS34UBv CC7KNaDz2YAZ64KRGS/vjsc+8lzgZ6iekVEJW9iWteKeJQHrufxtyFtax1cFpLnC4h688oaZ7V+ lCUXDYN60+34zrYXBrqB0QBTjuWZbipxps0Ki4XADaWs3ASqS7BZ+b2H52Ejj3fWXyFGkOmf4ho VmPuEb3iE8QvA52kaQlc/ST9XoGv0tcRJJVMndJpgBL/6UwqhN3Rxg3LWgbqkw3QvPdCNeFlRvc l0R4xcd/gfZLg4QlBn/N3HnSDLlI2eWu3rFpctMwNbI9xLLOzhutXrSwj+CB+HRx/0nc1TKA+Gn Du81/BLAcQBp6i8w7Tu9Q3GiCxQL9VyQx4euOm96nNO+r8umyKQTjoIJSGG12bm13DwguBM5QTb iP327XW/HUnDS5R/eV8710rNWQygrTT/EpZnydwBKR4sxGOLcKlFT52OmuVZDvhMJxE4+TqtLtv Afw X-Received: by 2002:a05:7300:bc08:b0:2a4:701a:b9ba with SMTP id 5a478bee46e88-2c7bc937c3cmr929977eec.14.1774935564304; Mon, 30 Mar 2026 22:39:24 -0700 (PDT) Received: from localhost.localdomain (104.194.93.216.16clouds.com. [104.194.93.216]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c3c747e410sm9271157eec.25.2026.03.30.22.39.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 22:39:24 -0700 (PDT) From: hkbinbin To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, hkbinbin , stable@vger.kernel.org Subject: [PATCH] Bluetooth: hci_sync: fix stack buffer overflow in hci_le_big_create_sync Date: Tue, 31 Mar 2026 05:39:16 +0000 Message-ID: <20260331053916.1856760-1-hkbinbinbin@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable hci_le_big_create_sync() uses DEFINE_FLEX to allocate a struct hci_cp_le_big_create_sync on the stack with room for 0x11 (17) BIS entries. However, conn->num_bis can hold up to HCI_MAX_ISO_BIS (31) entries =E2=80=94 validated against ISO_MAX_NUM_BIS (0x1f) in the caller hci_conn_big_create_sync(). When conn->num_bis is between 18 and 31, the memcpy that copies conn->bis into cp->bis writes up to 14 bytes past the stack buffer, corrupting adjacent stack memory. This is trivially reproducible: binding an ISO socket with bc_num_bis =3D ISO_MAX_NUM_BIS (31) and calling listen() will eventually trigger hci_le_big_create_sync() from the HCI command sync worker, causing a KASAN-detectable stack-out-of-bounds write: BUG: KASAN: stack-out-of-bounds in hci_le_big_create_sync+0x256/0x3b0 Write of size 31 at addr ffffc90000487b48 by task kworker/u9:0/71 Fix this by changing the DEFINE_FLEX count from the incorrect 0x11 to HCI_MAX_ISO_BIS, which matches the maximum number of BIS entries that conn->bis can actually carry. Fixes: 42ecf1947135 ("Bluetooth: ISO: Do not emit LE BIG Create Sync if pre= vious is pending") Cc: stable@vger.kernel.org Signed-off-by: hkbinbin Reviewed-by: Paul Menzel --- net/bluetooth/hci_sync.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 45d16639874a..b84587061ae0 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -7222,7 +7222,8 @@ static void create_big_complete(struct hci_dev *hdev,= void *data, int err) =20 static int hci_le_big_create_sync(struct hci_dev *hdev, void *data) { - DEFINE_FLEX(struct hci_cp_le_big_create_sync, cp, bis, num_bis, 0x11); + DEFINE_FLEX(struct hci_cp_le_big_create_sync, cp, bis, num_bis, + HCI_MAX_ISO_BIS); struct hci_conn *conn =3D data; struct bt_iso_qos *qos =3D &conn->iso_qos; int err; --=20 2.51.0