Skip to content

Commit

Permalink
ras-events: quit loop in read_ras_event when kbuf data is broken
Browse files Browse the repository at this point in the history
when kbuf data is broken, kbuffer_next_event() may move kbuf->index back to
the current kbuf->index position, causing dead loop.

In this situation, rasdaemon will repeatedly parse an invalid event, and
print warning like "ug! negative record size -8!", pushing cpu utilization
rate to 100%.

when kbuf data is broken, discard current page and continue reading next page
kbuf.

Signed-off-by: hubin <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
hubin authored and mchehab committed Oct 23, 2023
1 parent a247baf commit 794530f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ras-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
kbuffer_load_subbuffer(kbuf, page);

while ((data = kbuffer_read_event(kbuf, &time_stamp))) {
if (kbuffer_curr_size(kbuf) < 0) {
log(TERM, LOG_ERR, "invalid kbuf data, discard\n");
break;
}

parse_ras_data(&pdata[i],
kbuf, data, time_stamp);

Expand Down

0 comments on commit 794530f

Please sign in to comment.