Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer size declaration in syspapi #1366

Closed
wants to merge 1 commit into from

Conversation

baallan
Copy link
Collaborator

@baallan baallan commented Feb 27, 2024

pfm_name copy may be up to size of .info field being copied.
this uses the papi header macro to match.

pfm_name copy may be up to size of .info field being copied.
@baallan
Copy link
Collaborator Author

baallan commented Feb 27, 2024

@baallan need to cherry pick this to ovis-4

@@ -89,7 +89,7 @@ typedef struct syspapi_metric_s {
int init_rc; /* if 0, attr is good for perf_event_open() */
struct perf_event_attr attr; /* perf attribute */
char papi_name[256]; /* metric name in PAPI */
char pfm_name[256]; /* metric name in perfmon (PAPI native) */
char pfm_name[PAPI_HUGE_STR_LEN]; /* metric name in perfmon (PAPI native) */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baallan, I don't believe that this field is used anywhere. We should just remove it instead of consuming 1k for every papi metric.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tom95858 it is copied at line 251 into a buffer which is just 256 bytes while the papi source string is up to 1024. The alternative is to make the structure's pfm_name field separately allocated and freed, which would be a much bigger change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baallan, after it is copied in there it is never used again. My suggestion is to just remove the field instead of wasting 1k for every event.

@tom95858 tom95858 closed this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants