From: "Mar Dominguez" <mar@talkjune.com>
To: "Jan Harkes" <jaharkes@cs.cmu.edu>,
coda@cs.cmu.edu, codalist@coda.cs.cmu.edu,
"Christian Brauner" <brauner@kernel.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/3] coda: bound the symlink target in venus_readlink()
Date: Sat, 05 Dec 2026 23:33:50 +0000 [thread overview]
Message-ID: <lk9r5FjteaCTUIwPCFlP6QPAGqlRinQBAxj2@talkjune.com> (raw)
In-Reply-To: <tfLBlXSsENrGOxG5HdN3biVX0fkwN2YcNSzr@talkjune.com>
venus_readlink() copies the link target from the reply buffer using
coda_readlink.data as an offset and coda_readlink.count as a length,
without checking either against the reply size returned by Venus.
count is only clamped from above to *length - 1, so a malfunctioning
Venus returning a short reply, a negative count, or an out-of-range
offset would cause venus_readlink() to read past the reply buffer or
pass a negative length to memcpy().
As defensive hardening against a buggy or short reply from Venus,
reject a reply that is shorter than struct coda_readlink_out, has a
negative count, or whose target does not lie within the reply.
Found and written with an LLM coding assistant.
Signed-off-by: Mar Dominguez <mar@talkjune.com>
---
Changes in v2:
- Reframed as defensive hardening against a buggy or short reply from
Venus and dropped security wording, Fixes:, and Cc: stable.
- No code changes.
fs/coda/upcall.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index 3438119b5..8cf688a04 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -361,15 +361,25 @@ int venus_readlink(struct super_block *sb, struct CodaFid *fid,
error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
if (!error) {
+ size_t replen = outsize;
+ size_t offset = (unsigned long)outp->coda_readlink.data;
+
retlen = outp->coda_readlink.count;
+ /* The link target must lie within the reply Venus wrote. */
+ if (replen < sizeof(struct coda_readlink_out) || retlen < 0 ||
+ offset > replen || retlen > replen - offset) {
+ error = -EINVAL;
+ goto exit;
+ }
if (retlen >= *length)
retlen = *length - 1;
*length = retlen;
- result = (char *)outp + (long)outp->coda_readlink.data;
+ result = (char *)outp + offset;
memcpy(buffer, result, retlen);
*(buffer + retlen) = '\0';
}
+exit:
kvfree(inp);
return error;
}
--
2.53.0
next prev parent reply other threads:[~2026-12-05 23:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 23:31 [PATCH v2 0/3] coda: check and serialize Venus replies Mar Dominguez
2026-12-05 23:33 ` Mar Dominguez [this message]
2026-12-05 23:36 ` [PATCH v2 2/3] coda: bound the pioctl output in venus_pioctl() Mar Dominguez
2026-12-05 23:39 ` [PATCH v2 3/3] coda: hold vc_mutex while completing a Venus reply Mar Dominguez
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=lk9r5FjteaCTUIwPCFlP6QPAGqlRinQBAxj2@talkjune.com \
--to=mar@talkjune.com \
--cc=brauner@kernel.org \
--cc=coda@cs.cmu.edu \
--cc=codalist@coda.cs.cmu.edu \
--cc=jaharkes@cs.cmu.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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®