FPM: inner prev_execute_data walk in fpm_php_trace_dump() is not depth-bounded
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- operating-systems
Research direction
Start with sapi/fpm/fpm/fpm_php_trace.c, especially the inner while (prev) loop at line 126 and the outer callers_limit loop near line 181. Add a bound to the inner walk so cyclic prev_execute_data chains cannot keep the master reading child memory indefinitely. Check the existing FPM trace tests and confirm the walk stops at the bound while normal traces still work.
Written by the indexing model from the issue text.
Description
Description
In fpm_php_trace_dump() (sapi/fpm/fpm/fpm_php_trace.c), the outer frame loop is bounded by callers_limit = request_slowlog_trace_depth (default 20; decremented at sapi/fpm/fpm/fpm_php_trace.c:181).
The inner loop that searches for the nearest user-code frame has no iteration cap:
sapi/fpm/fpm/fpm_php_trace.c:126
while (prev) {
...
if (0 > fpm_trace_get_long(prev + offsetof(zend_execute_data, prev_execute_data), &l)) {
return -1;
}
prev = l;
}
It stops only on a user frame, an invalid pointer, or a ptrace read error. The walk reads the stopped (ptraced) child's memory from the master. A corrupted or cyclic prev_execute_data chain in a worker could spin the inner loop, keeping the master busy reading child memory.
The trigger is narrow — it needs slowlog + request_slowlog_timeout configured and the ability to corrupt VM stack memory in a worker — so this is a robustness nit rather than a security issue. Confirmed by source on PHP-8.6 and PHP-8.3.
Suggested fix
Bound the inner while (prev) loop with a counter (e.g. mirroring the outer callers_limit, or a hard cap), so a cyclic chain cannot hang the master.
PHP Version
PHP-8.6 and PHP-8.3 branch heads (confirmed by source).
Operating System
Linux
- Dominant language
- C
- Stars
- 41.9k
- Forks
- 8.5k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 117
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from php/php-src
-
FPM/FastCGI: FCGI_HASH_FUNC reads var[3] for 3-character names (guarded only by var_len < 3)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
php/php-src#26067 · 4 comments ·
Maintainers usually reply within 1 day
-
FPM: fpm_request_end() releases the scoreboard writer lock without acquiring it (8.6 regression)Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Bug Status: Verified
Difficulty 1/5 Under an hour Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
getimagesize(): WebP VP8 dimensions are accepted with an invalid start codePossibly taken @lazerg claimed this 5 days ago. OpenBug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
389ds/389-ds-base#8251 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ROCm/hrx-system#3628 ·
Maintainers usually reply within 1 day