Skip to content

Commit

Permalink
firmware: qemu_fw_cfg: fix sysfs information leak
Browse files Browse the repository at this point in the history
Make sure to always NUL-terminate file names retrieved from the firmware
to avoid accessing data beyond the entry slab buffer and exposing it
through sysfs in case the firmware data is corrupt.

Fixes: 75f3e8e ("firmware: introduce sysfs driver for QEMU's fw_cfg device")
Cc: [email protected]      # 4.6
Cc: Gabriel Somlo <[email protected]>
Signed-off-by: Johan Hovold <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
jhovold authored and mstsirkin committed Jan 14, 2022
1 parent 6004e35 commit 1b656e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/firmware/qemu_fw_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)
/* set file entry information */
entry->size = be32_to_cpu(f->size);
entry->select = be16_to_cpu(f->select);
memcpy(entry->name, f->name, FW_CFG_MAX_FILE_PATH);
strscpy(entry->name, f->name, FW_CFG_MAX_FILE_PATH);

/* register entry under "/sys/firmware/qemu_fw_cfg/by_key/" */
err = kobject_init_and_add(&entry->kobj, &fw_cfg_sysfs_entry_ktype,
Expand Down

0 comments on commit 1b656e9

Please sign in to comment.