Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

FPM: inner prev_execute_data walk in fpm_php_trace_dump() is not depth-bounded #26068

Backlog

Description

@fusionfoto

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions