summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>2026-06-07 20:19:04 +0800
committerDominique Martinet <asmadeus@codewreck.org>2026-09-13 08:26:00 +0000
commit9ee83ef8d24f11feb55fd0d222c0ec19f09dbd3f (patch)
tree7ba5149e8c0b8741ffef0dea7ad8fe3b70a709f2
parent0955472fff1e9f9e410a0300136924ebc8bd7a16 (diff)
downloadlinux-9ee83ef8d24f11feb55fd0d222c0ec19f09dbd3f.tar.gz
linux-9ee83ef8d24f11feb55fd0d222c0ec19f09dbd3f.zip
net/9p/usbg: fix prefix matching in device lookup
p9_usbg_create() matches the mount source against registered usb9pfs instance tags with strncmp() and the length of the caller supplied source. That accepts any prefix of the registered tag. For example, a gadget instance tagged "secret_channel" can be selected with "s", "sec", or any other non-empty prefix. Once selected, the instance is marked in use and the client is attached to that transport. This differs from the configfs tag lookup path, which uses strcmp() and therefore requires an exact tag match. Require an exact tag match in p9_usbg_create() as well. Fixes: a3be076dc174 ("net/9p/usbg: Add new usb gadget function transport") Cc: stable@vger.kernel.org Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn> Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn> Reported-by: Ao Wang <wangao@seu.edu.cn> Reported-by: Xuewei Feng <fengxw06@126.com> Reported-by: Qi Li <qli01@tsinghua.edu.cn> Reported-by: Ke Xu <xuke@tsinghua.edu.cn> Assisted-by: GLM:GLM-5.1 Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn> Co-developed-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Message-ID: <20260607121907.12588-1-zhaoyz24@mails.tsinghua.edu.cn> Message-ID: <20260719040346.88295-1-liu.yun@linux.dev> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
-rw-r--r--net/9p/trans_usbg.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c
index 23056b803ddf..021631d63318 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;