FPM: NULL dereference in fpm_status_export_to_zval() when the scoreboard copy fails (PHP-8.3)

Đang mở Phù hợp với người mới
#26,067 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, php
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu tại sapi/fpm/fpm/fpm_status.c, ở fpm_status_export_to_zval(), rồi so sánh mã PHP-8.3 với phần bảo vệ của PHP-8.6 được mô tả trong issue. Báo cáo cho biết fpm_get_status() trong sapi/fpm/fpm/fpm_main.c đi đến hàm này; hãy thêm xử lý NULL sau khi sao chép scoreboard và xác nhận hàm trả về -1 khi thất bại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

fpm_status_export_to_zval() in sapi/fpm/fpm/fpm_status.c dereferences the result of fpm_scoreboard_copy() without a NULL check:

scoreboard_p = fpm_scoreboard_copy(NULL, 1);   /* line 84 */

now_epoch = time(NULL);
fpm_clock_get(&now);

array_init(status);
add_assoc_string(status, "pool", scoreboard_p->pool);   /* line 90 -- no NULL check */

fpm_scoreboard_copy() can return NULL (allocation failure, or no scoreboard), and the result is dereferenced immediately, crashing the worker.

This is reachable from PHP userland via the fpm_get_status() builtin (sapi/fpm/fpm/fpm_main.c:1525, which calls fpm_status_export_to_zval() at :1531).

PHP-8.6 already guards this right after the copy (if (!scoreboard_p) { return -1; }); PHP-8.3 is missing the guard.

Not a cross-boundary vulnerability — the trigger is calling a documented PHP function plus a scoreboard-copy failure (e.g. under OOM); it is a self-crash (NULL dereference) of the calling worker.

Suggested fix

Backport the 8.6 guard to PHP-8.3: return -1 when fpm_scoreboard_copy() returns NULL. PR to follow.

PHP Version

PHP-8.3 branch at 3f52e69cdb (PHP 8.3.38-dev (fpm-fcgi), DEBUG).

Operating System

Linux

Ngôn ngữ chính
C
Star
41.9k
Fork
8.5k
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
117

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của php/php-src

Tất cả issue của php/php-src

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.