Skip to content

Commit

Permalink
Increase block_data size to allocate the uploaded firmware block
Browse files Browse the repository at this point in the history
Solve #194: the block_sz was reaching the value 23, and block_data had
only 20 bytes allocated (HPM_BLOCK_SIZE), so the memcpy call was
corrupting the stack. After returning from req_handler, the restored
value of R4 got corrupted resulting in an invalid memory
access in the xQueueReceive function.
  • Loading branch information
gustavosr8 authored and augustofg committed Mar 7, 2024
1 parent 37e2ad0 commit e88b30b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion modules/hpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ IPMI_HANDLER(ipmi_picmg_initiate_upgrade_action, NETFN_GRPEXT, IPMI_PICMG_CMD_HP
uint8_t len = rsp->data_len = 0;

uint8_t comp_id;

/* Set the component that'll be upgraded */
/*
* As specified in the Hardware Platform Management IPM Controller Firmware Upgrade Specification, Table 3-4,
Expand Down Expand Up @@ -310,6 +310,12 @@ IPMI_HANDLER(ipmi_picmg_upload_firmware_block, NETFN_GRPEXT, IPMI_PICMG_CMD_HPM_
uint8_t block_data[HPM_BLOCK_SIZE];
uint8_t block_sz = req->data_len-2;

if(block_sz > HPM_BLOCK_SIZE){
rsp->data_len = len;
rsp->completion_code = IPMI_CC_UNSPECIFIED_ERROR;
return;
}

if (active_component == NULL) {
/* Component ID out of range */
rsp->data[len++] = IPMI_PICMG_GRP_EXT;
Expand Down
4 changes: 2 additions & 2 deletions modules/hpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define HPM_ROLLBACK_TIMEOUT 10 /* in 5 seconds counts */
#define HPM_INACCESSIBILITY_TIMEOUT 10 /* in 5 seconds counts */

#define HPM_BLOCK_SIZE 20
#define HPM_BLOCK_SIZE 64

/* Components ID */
enum {
Expand All @@ -54,7 +54,7 @@ typedef uint8_t (* t_hpm_activate_firmware)(void);


/*
* Define the "Get target upgrade capabilities" message struct as define in the
* Define the "Get target upgrade capabilities" message struct as define in the
* Hardware Platform Management IPM Controller Firmware Upgrade Specification, Table 3-3
*/
typedef union {
Expand Down

0 comments on commit e88b30b

Please sign in to comment.