PAPI_event_code_to_name
potential memory risk
#8
Labels
type-bug
Issues discussing bugs or PRs fixing bugs
PAPI_event_code_to_name
potential memory risk
#8
For native events
PAPI_event_code_to_name(int EventCode, char *out)
calls_papi_hwi_native_code_to_name( EventCode, out, PAPI_MAX_STR_LEN)
. Thus, it assumes that the event name could be max 128 characters. There are several potential problems with this,PAPI_ENOMEM
which is not documented behavior. These long cuda events are all multipass (and cannot be measured) but PAPI event name<->code API should work for them too.char evt_name[64]
and callsPAPI_event_code_to_name(EventCode, evt_name)
then it's a buffer overflow. The example in docs showschar EventCodeStr[PAPI_MAX_STR_LEN]
but this is not mentioned as a requirement.PAPI API needs to account for possibly longer event names, and properly truncate at user string length. The function should be defined as
PAPI_event_code_to_name(int EventCode, char *out, int len)
.Alternatively, we can have a function that returns a pointer to a dynamically allocated string that the user needs to free.
The text was updated successfully, but these errors were encountered: