Linux USB
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>,
	Lukas Wunner <lukas@wunner.de>,
	Andreas Noever <andreas.noever@gmail.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Mika Westerberg <westeri@kernel.org>
Subject: [PATCH 4/9] thunderbolt: stream: Validate the ConfigFS group name more strictly
Date: Wed, 25 Nov 2026 16:26:17 +0100	[thread overview]
Message-ID: <20261125152623.456054-5-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20261125152623.456054-1-mika.westerberg@linux.intel.com>

From: "Mika Westerberg (Intel)" <westeri@kernel.org>

The ConfigFS group names must match the Thunderbolt service names so
passing something like "0-1.0a" will not match any service but it is
accepted at the moment. Make this more strict. We are going to need
this also later in the series when we introduce USB4STREAM coupling.

Signed-off-by: Mika Westerberg (Intel) <westeri@kernel.org>
---
 drivers/thunderbolt/stream.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/thunderbolt/stream.c b/drivers/thunderbolt/stream.c
index 2b73f585ccff..2661f563b99c 100644
--- a/drivers/thunderbolt/stream.c
+++ b/drivers/thunderbolt/stream.c
@@ -1763,16 +1763,24 @@ static const struct config_item_type tbstream_dev_group_type = {
 	.ct_item_ops = &tbstream_item_ops,
 };
 
+static bool tbstream_valid_service_name(const char *name)
+{
+	unsigned int domain, index;
+	int len = 0;
+	u64 route;
+
+	if (sscanf(name, "%u-%llx.%u%n", &domain, &route, &index, &len) != 3)
+		return false;
+	return len == strlen(name);
+}
+
 static struct config_group *
 tbstream_make_group(struct config_group *group, const char *name)
 {
 	struct tbstream_group *sg;
 	struct tbstream *stream;
-	int domain, index;
-	u64 route;
 
-	/* Make sure the format is correct */
-	if (sscanf(name, "%u-%llx.%u", &domain, &route, &index) != 3)
+	if (!tbstream_valid_service_name(name))
 		return ERR_PTR(-EINVAL);
 
 	sg = kzalloc_obj(*sg);
-- 
2.50.1


  parent reply	other threads:[~2026-11-25 15:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 15:26 [PATCH 0/9] thunderbolt: Introduce USB4STREAM coupling Mika Westerberg
2026-11-25 15:26 ` [PATCH 1/9] thunderbolt: Add and remove XDomain services outside of the state work Mika Westerberg
2026-11-25 15:26 ` [PATCH 2/9] thunderbolt: Unregister XDomains when the domain is removed Mika Westerberg
2026-11-25 15:26 ` [PATCH 3/9] thunderbolt: stream: Keep better track of the HopIDs Mika Westerberg
2026-11-25 15:26 ` Mika Westerberg [this message]
2026-11-25 15:26 ` [PATCH 5/9] thunderbolt: Allow DMA tunnel also between two lane adapters Mika Westerberg
2026-11-25 15:26 ` [PATCH 6/9] thunderbolt: Add KUnit tests for lane to lane DMA tunnels Mika Westerberg
2026-11-25 15:26 ` [PATCH 7/9] thunderbolt: Add tb_xdomains_enable_paths() and tb_xdomains_disable_paths() Mika Westerberg
2026-11-25 15:26 ` [PATCH 8/9] thunderbolt: stream: Introduce USB4STREAM coupling Mika Westerberg
2026-11-25 15:26 ` [PATCH 9/9] Documentation: thunderbolt: Document " Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125152623.456054-5-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=westeri@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox