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 527E91FCF41 for ; Fri, 5 Jun 2026 19:33: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=1780687993; cv=none; b=ghOYa20njzmbVTbtiSSPTbXYpsVCf9SgTcn7bZj1DHGJmB45USKLLmnjhrueVZJthaPcgfM1d98cwp8MOUqsLW5aCuBRtyW9K6yBmZU+vy4lISO2Zmrni4ziU8G1JcduEliNpJfqphK4AUWmz1KTgSuCNry5f2YlepHUDOlFmo4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780687993; c=relaxed/simple; bh=eO1D/7HHimVESp06My8yXIZ+NjNeKEhSuAmyH1iNWuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6E8htRJLp2MOuzBSbB4Ttd/R86Va2EuAlW1EVqnZqBPGEcQFv+rK3+AsGUNHvy5iNJfpgj07w8h3pVOLmby2i4/yKaGnmqV0e5qEABpn8irKXji8410yRRAb1V/2GVlNb58kCU4ovE3lp+Xt1zeiBdOc10YDlU+IsxwW6+8fwE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SouhojG0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SouhojG0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B640F1F00893; Fri, 5 Jun 2026 19:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780687992; bh=7lohqZ3Pz2MmjOECoBipy5pMiPHypi356NP1fy37EX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SouhojG0MXK0c6KBVgIiaCyal/SEXDnO6AevhkC20SuCChUHBkjbJEoeWcuamF9Gy eyp77LzsyMzJvV9Wfb+ryQ/vaDGYGzzZy1N2d/3tIUQVrmJ47Q1LOne4BswkFp+u6Q JklpkpPPEg9gZ2mMrdGhnQwK4UBXKxhDTpRw+gRbFXfkOJ8d6ndWoGI9sYYVlIRV/3 mTcOtaRiWGtaEiRnx04QG2RwRAuWyWddO13/ZC18N7bTLLt7OQxUbfw/QX8Uc8eptd xfXnPmaeT52czj7m4ogKGWUSnS2z+cEgI5qlmCJXJSS8JW4QEjhdbxNhj8izVTVWnQ Nt04ftThIjxBg== From: Sasha Levin To: stable@vger.kernel.org Cc: Michael Bommarito , Mika Westerberg , Sasha Levin Subject: [PATCH 6.12.y] thunderbolt: property: Cap recursion depth in __tb_property_parse_dir() Date: Fri, 5 Jun 2026 15:33:10 -0400 Message-ID: <20260605193310.2159165-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026060406-submitter-repackage-5f5e@gregkh> References: <2026060406-submitter-repackage-5f5e@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Michael Bommarito [ Upstream commit 928abe19fbf0127003abcb1ea69cabc1c897d0ab ] A DIRECTORY entry's value field is used as the dir_offset for a recursive call into __tb_property_parse_dir() with no depth counter. A crafted peer that chains DIRECTORY entries into a back-reference loop drives the parser until the kernel stack is exhausted and the guard page fires. Any untrusted XDomain peer (cable, dock, in-line inspector, adjacent host) that reaches the PROPERTIES_REQUEST control-plane exchange can trigger this without authentication. Thread a depth counter through tb_property_parse() and __tb_property_parse_dir(), and reject blocks that exceed TB_PROPERTY_MAX_DEPTH = 8. That is comfortably larger than any observed legitimate XDomain layout. Operators who do not need XDomain host-to-host discovery can disable the path entirely with thunderbolt.xdomain=0 on the kernel command line. Fixes: cdae7c07e3e3 ("thunderbolt: Add support for XDomain properties") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-6 Assisted-by: Codex:gpt-5-4 Signed-off-by: Michael Bommarito Signed-off-by: Mika Westerberg Signed-off-by: Sasha Levin --- drivers/thunderbolt/property.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/thunderbolt/property.c b/drivers/thunderbolt/property.c index dc555cda98e680..eaa808f3fbfcd3 100644 --- a/drivers/thunderbolt/property.c +++ b/drivers/thunderbolt/property.c @@ -34,10 +34,11 @@ struct tb_property_dir_entry { }; #define TB_PROPERTY_ROOTDIR_MAGIC 0x55584401 +#define TB_PROPERTY_MAX_DEPTH 8 static struct tb_property_dir *__tb_property_parse_dir(const u32 *block, size_t block_len, unsigned int dir_offset, size_t dir_len, - bool is_root); + bool is_root, unsigned int depth); static inline void parse_dwdata(void *dst, const void *src, size_t dwords) { @@ -93,7 +94,8 @@ tb_property_alloc(const char *key, enum tb_property_type type) } static struct tb_property *tb_property_parse(const u32 *block, size_t block_len, - const struct tb_property_entry *entry) + const struct tb_property_entry *entry, + unsigned int depth) { char key[TB_PROPERTY_KEY_SIZE + 1]; struct tb_property *property; @@ -114,7 +116,7 @@ static struct tb_property *tb_property_parse(const u32 *block, size_t block_len, switch (property->type) { case TB_PROPERTY_TYPE_DIRECTORY: dir = __tb_property_parse_dir(block, block_len, entry->value, - entry->length, false); + entry->length, false, depth + 1); if (!dir) { kfree(property); return NULL; @@ -159,13 +161,17 @@ static struct tb_property *tb_property_parse(const u32 *block, size_t block_len, } static struct tb_property_dir *__tb_property_parse_dir(const u32 *block, - size_t block_len, unsigned int dir_offset, size_t dir_len, bool is_root) + size_t block_len, unsigned int dir_offset, size_t dir_len, bool is_root, + unsigned int depth) { const struct tb_property_entry *entries; size_t i, content_len, nentries; unsigned int content_offset; struct tb_property_dir *dir; + if (depth > TB_PROPERTY_MAX_DEPTH) + return NULL; + dir = kzalloc(sizeof(*dir), GFP_KERNEL); if (!dir) return NULL; @@ -192,7 +198,7 @@ static struct tb_property_dir *__tb_property_parse_dir(const u32 *block, for (i = 0; i < nentries; i++) { struct tb_property *property; - property = tb_property_parse(block, block_len, &entries[i]); + property = tb_property_parse(block, block_len, &entries[i], depth); if (!property) { tb_property_free_dir(dir); return NULL; @@ -229,7 +235,7 @@ struct tb_property_dir *tb_property_parse_dir(const u32 *block, return NULL; return __tb_property_parse_dir(block, block_len, 0, rootdir->length, - true); + true, 0); } /** -- 2.53.0