mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
firmware: arm_scmi: Avoid using extended string-buffers sizes if not necessary
Commitb260fccaeb
("firmware: arm_scmi: Add SCMI v3.1 protocol extended names support") moved all the name string buffers to use the extended buffer size of 64 instead of the required 16 bytes. While that should be fine if the firmware terminates the string before 16 bytes, there is possibility of copying random data if the name is not NULL terminated by the firmware. SCMI base protocol agent_name/vendor_id/sub_vendor_id are defined by the specification as NULL-terminated ASCII strings up to 16-bytes in length. The underlying buffers and message descriptors are currently bigger than needed; resize them to fit only the strictly needed 16 bytes to avoid any possible leaks when reading data from the firmware. Change the size argument of strlcpy to use SCMI_SHORT_NAME_MAX_SIZE always when dealing with short domain names, so as to limit the possibility that an ill-formed non-NULL terminated short reply from the SCMI platform firmware can leak stale content laying in the underlying transport shared memory area. While at that, convert all strings handling routines to use the preferred strscpy. Link: https://lore.kernel.org/r/20220608095530.497879-1-cristian.marussi@arm.com Fixes:b260fccaeb
("firmware: arm_scmi: Add SCMI v3.1 protocol extended names support") Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
parent
8e60294c80
commit
4314f9f4f8
9 changed files with 16 additions and 17 deletions
|
@ -13,8 +13,9 @@
|
|||
#include <linux/notifier.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define SCMI_MAX_STR_SIZE 64
|
||||
#define SCMI_MAX_NUM_RATES 16
|
||||
#define SCMI_MAX_STR_SIZE 64
|
||||
#define SCMI_SHORT_NAME_MAX_SIZE 16
|
||||
#define SCMI_MAX_NUM_RATES 16
|
||||
|
||||
/**
|
||||
* struct scmi_revision_info - version information structure
|
||||
|
@ -36,8 +37,8 @@ struct scmi_revision_info {
|
|||
u8 num_protocols;
|
||||
u8 num_agents;
|
||||
u32 impl_ver;
|
||||
char vendor_id[SCMI_MAX_STR_SIZE];
|
||||
char sub_vendor_id[SCMI_MAX_STR_SIZE];
|
||||
char vendor_id[SCMI_SHORT_NAME_MAX_SIZE];
|
||||
char sub_vendor_id[SCMI_SHORT_NAME_MAX_SIZE];
|
||||
};
|
||||
|
||||
struct scmi_clock_info {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue