New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 757027 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

ec: log_add_event() allows payload[] size of up to 31 bytes

Project Member Reported by sha...@chromium.org, Aug 18 2017

Issue description

vbendeb@ pointed out this discrepency when wondering how large of a buffer is needed to pass to log_dequeue_event().

struct event_log_entry {
	uint32_t timestamp; /* relative timestamp in milliseconds */
	uint8_t type;       /* event type, caller-defined */
	uint8_t size;       /* [7:5] caller-def'd [4:0] payload size in bytes */
	uint16_t data;      /* type-defined data payload */
	uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
} __packed;

Size is represented by five bits, and since we aren't enforcing that the payload size is limited to 16 (though in practice we don't write more than 16 payload bytes), it's possible to have payload size up to 31 bytes.

If we want to limit the payload size to 16 bytes, we can modify EVENT_LOG_SIZE() to enforce the limit.
 

Sign in to add a comment