From: Michael Bommarito <michael.bommarito@gmail.com>
To: Eric Van Hensbergen <ericvh@kernel.org>,
Latchesar Ionkov <lucho@ionkov.net>,
Dominique Martinet <asmadeus@codewreck.org>,
Christian Schoenebeck <linux_oss@crudebyte.com>
Cc: v9fs@lists.linux.dev, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] 9p/trans_virtio: bound mount_tag show copy to one page
Date: Wed, 10 Jun 2026 07:42:06 -0400 [thread overview]
Message-ID: <20260610114206.3749904-1-michael.bommarito@gmail.com> (raw)
p9_mount_tag_show() copies strlen(chan->tag) + 1 bytes into the
single-page buffer the sysfs core provides, with no upper bound. The
mount tag length comes from virtio_9p_config.tag_len, a 16-bit field read
from the device at probe in p9_virtio_probe() with no cap. Under the
confidential-computing threat model, where the guest does not trust the
host, a malicious or compromised host can present a 65535-byte tag with
no embedded NUL. A read of the world-readable /sys/.../mount_tag
attribute (udev reads it at probe) then copies ~64 KiB into the 4 KiB
sysfs page, a slab-out-of-bounds write of host-controlled content.
Bound the copy to the page size in the show handler.
Fixes: 179a5bc4b8cb ("net/9p: use memcpy() instead of snprintf() in p9_mount_tag_show()")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
---
net/9p/trans_virtio.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 4cdab7094b273..b62aa7b309f1c 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -573,7 +573,11 @@ static ssize_t p9_mount_tag_show(struct device *dev,
chan = vdev->priv;
tag_len = strlen(chan->tag);
- memcpy(buf, chan->tag, tag_len + 1);
+ if (tag_len > PAGE_SIZE - 2)
+ tag_len = PAGE_SIZE - 2;
+
+ memcpy(buf, chan->tag, tag_len);
+ buf[tag_len] = '\0';
return tag_len + 1;
}
--
2.53.0
next reply other threads:[~2026-06-10 11:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 11:42 Michael Bommarito [this message]
2026-06-10 15:46 ` Christian Schoenebeck
2026-06-10 16:00 ` Michael Bommarito
2026-06-26 11:19 ` [PATCH v3] 9p/trans_virtio: reject mount tags that cannot fit a sysfs page Michael Bommarito
2026-06-26 12:34 ` Christian Schoenebeck
2026-06-27 21:10 ` [PATCH v4] 9p/trans_virtio: reject mount tags longer than NAME_MAX at probe Michael Bommarito
2026-07-03 15:14 ` Christian Schoenebeck
2026-09-13 9:00 ` Dominique Martinet
2026-06-29 11:57 ` [PATCH v3] 9p/trans_virtio: reject mount tags that cannot fit a sysfs page kernel test robot
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=20260610114206.3749904-1-michael.bommarito@gmail.com \
--to=michael.bommarito@gmail.com \
--cc=asmadeus@codewreck.org \
--cc=ericvh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=stable@vger.kernel.org \
--cc=v9fs@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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
all inboxes | Powered by JetHome®