mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
platform/olpc: Reserve space for a string terminator
ec_dbgfs_cmd_write() copies user input into a zero-initialized stack
buffer and passes it to sscanf(). A write that overwrites the entire
buffer leaves no terminator, so the subsequent parsing can read beyond
the buffer.
Limit the copy to leave room for the trailing NUL.
Fixes: 6cca83d498 ("Platform: OLPC: move debugfs support from x86 EC driver")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Link: https://patch.msgid.link/20260926121250.3258285-2-yaojiale02@163.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
ae53bb89b9
commit
1fe88b1741
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user