From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4E6350B43F for ; Tue, 29 Sep 2026 11:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790682613; cv=none; b=UoEZVp38mpIx/4HC/Gyr4r7gTVFLlhi2dABE7o8WIjBBC2y/EbyVb3+R1Hn/ivU6vDtmkehXwZ439MYcSSZXt7HNC/gIJB0pkF2ep3/eFbmw7+pQHKoa1BprEq+XwyOQcYHuQ3V9vSvo3vnBsid3J0Sz8lBIRiyCxqrwl5NSbPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790682613; c=relaxed/simple; bh=FTIXZTgTjpxoT1us3qrM8mLOLXr0PekGQLu29WwXpOo=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=NA+qvh4oXaGfBsLmGHuvRCPuDsA6OCgJUIgj44bDFhBZkc91Ygsp1+0ICNWCWQXAk7n8GmzwRvBz37pGG71pvUMecP9+GyBk9YbYvTplQqU2LYjc6OkbDcC1Zi8KqErDVGGmGC0rSgdBV8oroB+XleZlGFV/HkYIuFpi2VfUkKc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tVv2bePi; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="tVv2bePi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CADB11F000FF; Tue, 29 Sep 2026 11:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790682612; bh=UkvtE9ovAC8+PaxQchGD+ztGvxlWMXsPGeAklNcFd/I=; h=Subject:To:Cc:From:Date; b=tVv2bePipnBWwLjLAza/YBIygaBBz1jayyx6ZDDL80ClfS2dVWlrGC9cCTDr5TCQB OE+n2zh+X+6DJRJ+sWh3SlaP+S4+jwWhrk+rKFb9a0BcAS9MyqVO3S1Rp0/cQRjc5l K1EJ5MRgmgb4SYJDNGBtb8NdLn+gI9jswvdA8gtc= Subject: FAILED: patch "[PATCH] Bluetooth: mgmt: fix race in read_unconf_index_list()" failed to apply to 5.10-stable tree To: qwe.aldo@gmail.com,luiz.von.dentz@intel.com Cc: From: Date: Tue, 29 Sep 2026 13:49:58 +0200 Message-ID: <2026092958-commerce-gangly-faea@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x b5dbb41b212c50c095a4dbee3017a84fe94f033b # git commit -s git send-email --to '' --in-reply-to '2026092958-commerce-gangly-faea@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From b5dbb41b212c50c095a4dbee3017a84fe94f033b Mon Sep 17 00:00:00 2001 From: Aldo Ariel Panzardo Date: Tue, 15 Sep 2026 12:59:52 -0300 Subject: [PATCH] Bluetooth: mgmt: fix race in read_unconf_index_list() read_unconf_index_list() counts unconfigured controllers before allocating its response, then checks the device flags again while filling it. hci_dev_list_lock stabilizes list membership, but it does not serialize the per-device flags. During asynchronous controller setup, the worker can set HCI_UNCONFIGURED and clear HCI_SETUP between the two passes. A controller omitted from the allocation count can then become eligible for the fill pass, causing an out-of-bounds write to rp->index[]. Allocate space for every device on hci_dev_list. Since list membership cannot change while hci_dev_list_lock is held, the response remains large enough regardless of flag transitions. The reported count and response length still include only eligible unconfigured controllers. Fixes: 73d1df2a7a10 ("Bluetooth: Add support for Read Unconfigured Index List command") Cc: stable@vger.kernel.org Signed-off-by: Aldo Ariel Panzardo Signed-off-by: Luiz Augusto von Dentz diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f740e745ae78..41956cdde982 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -496,13 +496,9 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev, read_lock(&hci_dev_list_lock); - count = 0; - list_for_each_entry(d, &hci_dev_list, list) { - if (hci_dev_test_flag(d, HCI_UNCONFIGURED)) - count++; - } + count = list_count_nodes(&hci_dev_list); - rp_len = sizeof(*rp) + (2 * count); + rp_len = sizeof(*rp) + (sizeof(__le16) * count); rp = kmalloc(rp_len, GFP_ATOMIC); if (!rp) { read_unlock(&hci_dev_list_lock);