php / php/php-src

Add a way to reserve shmop memory ids and prevent shmop_open (e.g. opcache's region)

Open
#9,951 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: opcache Extension: shmop Extension: sysvshm Feature Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

https://github.com/php/php-src/blob/5a5037f223c887d09e3131b2124cd7ff5a50cca9/ext/opcache/shared_alloc_shm.c#L112

Related to https://github.com/php/php-src/issues/9944

Prevent accidentally or intentionally reading or writing to shared memory regions which would be used by opcache, or other extensions such as APCu

A possible approach:

  1. Add a helper method in Zend/ directory to track ids used during module initialization
  2. Make the ext/shmop extension check if those ids were already used and treat it like a native error code for https://php.net/shmop_open
  3. Add an ini setting to disable this protection, in case userland debuggers/visualizers have valid use cases for this

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading ext/opcache/shared_alloc_shm.c at the linked location, then inspect the ext/shmop implementation and the Zend/ directory. Determine how module initialization could track reserved IDs and how shmop_open reports native errors. Done means opcache and other extension regions cannot be accessed accidentally, with the proposed opt-out ini setting considered.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
operating-systems, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.