From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D62A122AE5D; Fri, 21 Nov 2025 13:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763733134; cv=none; b=aQV/R3MMwoREc1r7mcW8tAJuHndspQUzmhZqEKDSKyYXAGiXdViIqD6akRbvL0JJM1mfZTLEL1j53G7IVVC9aMSp2WLlfiaF722xZArsKS2pDFPlIdLZgSb1olvsWs67eK+nlqtbd2xw81Y4WRaF/NIJ6x0Be6Qe32/iLuXM7VY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763733134; c=relaxed/simple; bh=uL0DkiDf5cVQLnshImZT19vnp5QjANCcTp36uOKZL7o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ud2M8tJziFofiwTE71mjkFSxt29So66vUO5M24BUAhko16/pi7WKUnlmBWgySyzjK+7LXxRRP/A023mURxzrdJGO/YHRvTrV9MPEAEPbal9PWYavZ87WD1dHMbCikamP+ngBYfgJxsnt7udAirwV6ErUT1MIM/lrynVZfInF7ZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vgP+ofIz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vgP+ofIz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58186C4CEFB; Fri, 21 Nov 2025 13:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1763733134; bh=uL0DkiDf5cVQLnshImZT19vnp5QjANCcTp36uOKZL7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vgP+ofIziy8kagLuhvhj32b+NSnZiPrvqlc3/bCxcIlFX2q+3/NjPgzzhUiIsfOV9 GKWtTctWouvuW11YGx/3FbY310zFbkugKb1XMh1Htf6++gjU8xHMYN32I14z2HKBOP tF9IB41P5WTcirnJwDvTUyAm879pf5KXCSej8/q4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ilia Gavrilov , Luiz Augusto von Dentz Subject: [PATCH 6.6 364/529] Bluetooth: MGMT: Fix OOB access in parse_adv_monitor_pattern() Date: Fri, 21 Nov 2025 14:11:03 +0100 Message-ID: <20251121130243.981021465@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121130230.985163914@linuxfoundation.org> References: <20251121130230.985163914@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilia Gavrilov commit 8d59fba49362c65332395789fd82771f1028d87e upstream. In the parse_adv_monitor_pattern() function, the value of the 'length' variable is currently limited to HCI_MAX_EXT_AD_LENGTH(251). The size of the 'value' array in the mgmt_adv_pattern structure is 31. If the value of 'pattern[i].length' is set in the user space and exceeds 31, the 'patterns[i].value' array can be accessed out of bound when copied. Increasing the size of the 'value' array in the 'mgmt_adv_pattern' structure will break the userspace. Considering this, and to avoid OOB access revert the limits for 'offset' and 'length' back to the value of HCI_MAX_AD_LENGTH. Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE. Fixes: db08722fc7d4 ("Bluetooth: hci_core: Fix missing instances using HCI_MAX_AD_LENGTH") Cc: stable@vger.kernel.org Signed-off-by: Ilia Gavrilov Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- include/net/bluetooth/mgmt.h | 2 +- net/bluetooth/mgmt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -774,7 +774,7 @@ struct mgmt_adv_pattern { __u8 ad_type; __u8 offset; __u8 length; - __u8 value[31]; + __u8 value[HCI_MAX_AD_LENGTH]; } __packed; #define MGMT_OP_ADD_ADV_PATTERNS_MONITOR 0x0052 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5358,9 +5358,9 @@ static u8 parse_adv_monitor_pattern(stru for (i = 0; i < pattern_count; i++) { offset = patterns[i].offset; length = patterns[i].length; - if (offset >= HCI_MAX_EXT_AD_LENGTH || - length > HCI_MAX_EXT_AD_LENGTH || - (offset + length) > HCI_MAX_EXT_AD_LENGTH) + if (offset >= HCI_MAX_AD_LENGTH || + length > HCI_MAX_AD_LENGTH || + (offset + length) > HCI_MAX_AD_LENGTH) return MGMT_STATUS_INVALID_PARAMS; p = kmalloc(sizeof(*p), GFP_KERNEL);