-
Notifications
You must be signed in to change notification settings - Fork 4
Fix crash in execve filename parameter parsing #98
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
base: 0.23.1-stackrox
Are you sure you want to change the base?
Changes from all commits
50ee906
713d313
ec3747c
a4c9d16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1730,6 +1730,69 @@ void sinsp_evt_param::throw_invalid_len_error(size_t requested_length) const { | |
| "parameter raw data: \n" + buffer_to_multiline_hex(param_data, param_len), | ||
| sinsp_logger::SEV_ERROR); | ||
|
|
||
| // Enhanced diagnostics: dump raw event structure to identify the | ||
| // root cause of parameter corruption (ROX-33614 investigation). | ||
| const scap_evt *raw = m_evt->get_scap_evt(); | ||
| const ppm_event_info *evtinfo = m_evt->get_info(); | ||
| if(raw && evtinfo) { | ||
| std::stringstream diag; | ||
| diag << "event diagnostics:" | ||
| << " hdr_nparams=" << raw->nparams | ||
| << " table_nparams=" << evtinfo->nparams | ||
| << " event_len=" << raw->len | ||
| << " event_type=" << raw->type | ||
| << " hdr_size=" << sizeof(struct ppm_evt_hdr); | ||
| libsinsp_logger()->log(diag.str(), sinsp_logger::SEV_ERROR); | ||
|
|
||
| // Dump the length array from the raw event. | ||
| // Layout: [ppm_evt_hdr][len0][len1]...[lenN][data0][data1]... | ||
| // Each length entry is uint16_t (non-large) or uint32_t (large). | ||
| const char *evt_base = reinterpret_cast<const char *>(raw); | ||
| const char *len_array = evt_base + sizeof(struct ppm_evt_hdr); | ||
| bool is_large = (evtinfo->flags & EF_LARGE_PAYLOAD) != 0; | ||
| uint32_t len_entry_size = is_large ? sizeof(uint32_t) : sizeof(uint16_t); | ||
| uint32_t len_array_bytes = raw->nparams * len_entry_size; | ||
|
|
||
| // Dump all param lengths from the raw length array. | ||
| std::stringstream lens; | ||
| lens << "raw param lengths (" << (is_large ? "large" : "u16") << "):"; | ||
| for(uint32_t i = 0; i < raw->nparams && i < PPM_MAX_EVENT_PARAMS; i++) { | ||
| uint32_t plen = 0; | ||
| if(is_large) { | ||
| memcpy(&plen, len_array + i * sizeof(uint32_t), sizeof(uint32_t)); | ||
| } else { | ||
| uint16_t plen16 = 0; | ||
| memcpy(&plen16, len_array + i * sizeof(uint16_t), sizeof(uint16_t)); | ||
| plen = plen16; | ||
| } | ||
| lens << " [" << i << "]=" << plen; | ||
| } | ||
| libsinsp_logger()->log(lens.str(), sinsp_logger::SEV_ERROR); | ||
|
|
||
| // Dump the raw event header + length array as hex. | ||
| size_t hdr_and_lens = sizeof(struct ppm_evt_hdr) + len_array_bytes; | ||
| size_t dump_len = std::min(hdr_and_lens, (size_t)256); | ||
| libsinsp_logger()->log( | ||
| "raw header+lengths (" + std::to_string(dump_len) + " bytes):\n" + | ||
| buffer_to_multiline_hex(evt_base, dump_len), | ||
| sinsp_logger::SEV_ERROR); | ||
|
|
||
| // Dump the first 128 bytes of the param data region. | ||
| const char *data_region = len_array + len_array_bytes; | ||
| size_t data_avail = 0; | ||
| if(raw->len > hdr_and_lens) { | ||
| data_avail = raw->len - hdr_and_lens; | ||
| } | ||
| size_t data_dump = std::min(data_avail, (size_t)128); | ||
| if(data_dump > 0) { | ||
| libsinsp_logger()->log( | ||
| "param data region (first " + std::to_string(data_dump) + | ||
| " of " + std::to_string(data_avail) + " bytes):\n" + | ||
| buffer_to_multiline_hex(data_region, data_dump), | ||
| sinsp_logger::SEV_ERROR); | ||
|
Comment on lines
+1750
to
+1792
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Validate raw-event bounds before reading diagnostic fields. The invalid-length path trusts Limit decoded entries to As per path instructions, focus on major issues impacting performance, readability, maintainability and security. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| } | ||
| } | ||
|
|
||
| throw sinsp_exception(error_string); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Release the task entry on every exit path.
maps__release_auxiliary_map()runs only afterbpf_ringbuf_output(). The!rbbranch at Line 127, the!counterbranch at Line 132, and the oversized-event branch at Line 141 return before this block. Those paths leave the current task's entry inauxiliary_maps.Repeated dropped events can fill the LRU and evict an entry still used by another in-flight event. Route all early returns through a common
out:cleanup block, or release the entry before each return.Proposed cleanup path
if(!rb) { ... - return; + goto out; } if(!counter) { - return; + goto out; } if(auxmap->payload_pos > MAX_EVENT_SIZE) { ... - return; + goto out; } +out: maps__release_auxiliary_map(); return;🤖 Prompt for AI Agents