summaryrefslogtreecommitdiff
path: root/arch/um/drivers
diff options
context:
space:
mode:
authorShengzhuo Wei <me@cherr.cc>2026-04-25 04:29:24 +0800
committerJohannes Berg <johannes.berg@intel.com>2026-09-24 16:21:50 +0200
commitaf20aad1ddcea3e74a1c779a84a57fc9e9cbdd08 (patch)
tree090faf29fda3161a1b1e8f85da469dd76a466846 /arch/um/drivers
parent9756ecdbffe61797fe1c81bc62ca48eaa27d4055 (diff)
um: mconsole: Fix out-of-bounds read in mconsole_log()
mconsole_parse() matches the 3-byte prefix "log", but mconsole_log() skips strlen("log ") = 4 bytes, advancing ptr past the NUL terminator when a client sends "log" without a trailing space. The length then comes from req->len, the raw recvfrom() count, instead of req->request.len, so printk() reads up to req->len - 4 bytes of stale data from a previous request left in the static mc_request buffer, leaking it to the kernel log. Use req->cmd->command for the actual command length, add skip_spaces(), use req->request.len, and guard against non-positive length. Signed-off-by: Shengzhuo Wei <me@cherr.cc> Link: https://patch.msgid.link/20260425-mconsole-oob-read-leak-v1-1-7d46e5892c5c@cherr.cc Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/mconsole_kern.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 18d0ec15557c..f01b7d8a07bc 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -117,10 +117,12 @@ void mconsole_log(struct mc_request *req)
int len;
char *ptr = req->request.data;
- ptr += strlen("log ");
+ ptr += strlen(req->cmd->command);
+ ptr = skip_spaces(ptr);
- len = req->len - (ptr - req->request.data);
- printk(KERN_WARNING "%.*s", len, ptr);
+ len = req->request.len - (ptr - req->request.data);
+ if (len > 0)
+ printk(KERN_WARNING "%.*s", len, ptr);
mconsole_reply(req, "", 0, 0);
}