FPM: fpm_request_end() releases the scoreboard writer lock without acquiring it (8.6 regression)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 sapi/fpm/fpm/fpm_request.c 中 fpm_request_end() 附近的程式碼,並將其中對 scoreboard 的呼叫與同一檔案中的 begin/commit 配對進行比較。檢查 sapi/fpm/fpm/fpm_scoreboard.c 中的鎖定行為;issue 指出了缺少的呼叫,以及將其安全地放在 fpm_scoreboard_proc_release(proc) 之後的位置。完成標準是:request end 在提交前取得寫入鎖,且 proc == NULL 返回路徑維持不變。
由索引模型根據 Issue 內容生成。
描述
Description
In PHP 8.6 the FPM scoreboard write path was split into two halves:
fpm_scoreboard_update_begin()acquiresscoreboard->writer_activeand waits forreader_count == 0.fpm_scoreboard_update_commit()writes the shared counters and then releaseswriter_active(fpm_unlock(scoreboard->writer_active);,sapi/fpm/fpm/fpm_scoreboard.c:218).
Every writer pairs the two calls — e.g. in sapi/fpm/fpm/fpm_request.c at lines 45/58 and 77/102 — except fpm_request_end(), which calls only commit:
sapi/fpm/fpm/fpm_request.c:205
fpm_scoreboard_update_commit(-1, -1, -1, -1, -1, -1, -1, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
with no preceding fpm_scoreboard_update_begin().
Because commit ends by releasing writer_active, at the end of every request fpm_request_end():
- releases a writer lock it never acquired — if another process legitimately holds
writer_activeat that moment, this clears it, letting a second writer and readers run concurrently with it; and - updates the shared counters (
memory_peak,active_max, ...) without first ensuringreader_count == 0, so a concurrent?fullstatus reader (fpm_scoreboard_copy) can read a torn scoreboard.
This is a correctness regression from the 8.6 begin/commit split (8.3 has no such split — it uses a single fpm_scoreboard_update()), not a memory-safety issue: the scoreboard is a fixed shared struct of scalars, so the consequences are limited to garbled status/metrics and a possible writer-lock imbalance.
Suggested fix
Add the matching fpm_scoreboard_update_begin(NULL) immediately before the commit in fpm_request_end() (after fpm_scoreboard_proc_release(proc)), so the writer lock is held across the shared-counter update. Placing begin right before commit (rather than at function entry, as the other sites do) avoids leaking the writer lock on the proc == NULL early-return path. PR to follow.
PHP Version
PHP-8.6 branch at 47abe238897 (PHP 8.6.2-dev (fpm-fcgi), NTS DEBUG).
Operating System
Linux
- 主要語言
- C
- 星號
- 41.9k
- 分支
- 8.5k
- 平均合併
- 2 天 16 小時
- 30 天內合併 PR
- 117
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
php/php-src 的其他 Issue
-
FPM/FastCGI: FCGI_HASH_FUNC reads var[3] for 3-character names (guarded only by var_len < 3)可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
Bug Status: Verified
難度 1/5 1 小時以內 新手友好度 74/100
維護者通常 1 天內回覆
-
getimagesize(): WebP VP8 dimensions are accepted with an invalid start code可能已有人在做 @lazerg 於 5 天前認領。 未關閉Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
相似的 Issue
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBuffer未關閉
難度 2/5 1-3 小時 新手友好度 78/100
-
needs triage
難度 2/5 1-3 小時 新手友好度 72/100
389ds/389-ds-base#8251 ·
維護者通常 1 天內回覆
-
bug data-types
難度 2/5 1-3 小時 新手友好度 76/100
ClickHouse/clickhouse-cpp#645 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
ROCm/hrx-system#3628 ·
維護者通常 1 天內回覆