Linux 9p file system development
 help / color / mirror / Atom feed
* [PATCH] net/9p/usbg: require an exact match for device tags
@ 2026-07-19  4:03 Jackie Liu
  0 siblings, 0 replies; only message in thread
From: Jackie Liu @ 2026-07-19  4:03 UTC (permalink / raw)
  To: ericvh; +Cc: asmadeus, linux_oss, v9fs

From: Jackie Liu <liuyun01@kylinos.cn>

p9_usbg_create() compares only strlen(devname) bytes while looking up the
configfs instance named by the mount source. A source that is a prefix of
an instance name therefore selects that instance. For example, source
"foo" binds the "foobar" channel instead of failing with -ENOENT.

The configfs layer passes the instance name to usb9pfs_set_inst_tag(), and
the transport already uses full string comparisons to keep these names
unique. Use an exact match for mount lookup too.

Fixes: a3be076dc174 ("net/9p/usbg: Add new usb gadget function transport")
Cc: stable@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 net/9p/trans_usbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c
index 419cda13a7b5..884d6f4af50c 100644
--- a/net/9p/trans_usbg.c
+++ b/net/9p/trans_usbg.c
@@ -391,7 +391,7 @@ static int p9_usbg_create(struct p9_client *client, struct fs_context *fc)
 	guard(mutex)(&usb9pfs_lock);
 
 	list_for_each_entry(dev, &usbg_instance_list, usb9pfs_instance) {
-		if (!strncmp(devname, dev->tag, strlen(devname))) {
+		if (!strcmp(devname, dev->tag)) {
 			if (!dev->inuse) {
 				dev->inuse = true;
 				found = 1;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-19  4:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-19  4:03 [PATCH] net/9p/usbg: require an exact match for device tags Jackie Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox