All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiale Yao <yaojiale02@163.com>
To: "Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Andres Salomon" <dilinger@queued.net>,
	"Thomas Gleixner" <tglx@kernel.org>, "Paul Fox" <pgf@laptop.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Jiale Yao <yaojiale02@163.com>
Subject: [PATCH 1/3] platform/olpc: Reserve space for a string terminator
Date: Sat, 26 Sep 2026 20:12:48 +0800	[thread overview]
Message-ID: <20260926121250.3258285-2-yaojiale02@163.com> (raw)
In-Reply-To: <20260926121250.3258285-1-yaojiale02@163.com>

ec_dbgfs_cmd_write() copies user input into a zero-initialized stack
buffer and passes it to sscanf(). A write that fills the entire buffer
overwrites its only terminator, so the subsequent parsing can read beyond
the buffer.

Limit the copy to leave room for the trailing NUL.

Fixes: 6cca83d498bd ("Platform: OLPC: move debugfs support from x86 EC driver")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
 drivers/platform/olpc/olpc-ec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 4a2d36f7331e..063f7e55c421 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -269,7 +269,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
 
 	mutex_lock(&ec_dbgfs_lock);
 
-	size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
+	size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf) - 1, ppos, buf, size);
 
 	m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0],
 			&ec_dbgfs_resp_bytes, &ec_cmd_int[1], &ec_cmd_int[2],
-- 
2.34.1


  reply	other threads:[~2026-09-26 12:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26 12:12 [PATCH 0/3] debugfs: Reserve space for string terminators Jiale Yao
2026-09-26 12:12 ` Jiale Yao [this message]
2026-09-26 12:12 ` [PATCH 2/3] wifi: ath12k: Reserve space for a string terminator Jiale Yao
2026-09-26 12:33   ` Dan Carpenter
2026-09-28 17:36   ` Rameshkumar Sundaram
2026-09-29  2:35   ` Baochen Qiang
2026-10-03 23:07   ` Jeff Johnson
2026-09-26 12:12 ` [PATCH 3/3] dmaengine: xilinx: dpdma: " Jiale Yao
2026-09-26 14:34   ` Laurent Pinchart
2026-10-01 20:50     ` Frank Li
2026-10-01 21:00       ` Laurent Pinchart
2026-10-03 10:09         ` jiale yao
2026-10-04  1:01           ` Frank Li
2026-10-08 17:38 ` [PATCH 0/3] debugfs: Reserve space for string terminators Ilpo Järvinen

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=20260926121250.3258285-2-yaojiale02@163.com \
    --to=yaojiale02@163.com \
    --cc=dilinger@queued.net \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pgf@laptop.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=tglx@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.