SysV shm: write back on munmap and drop attaches at exec

Open
#497 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, macos

Research direction

Start by tracing the SysV shared memory attach records and the sys_munmap and exec paths; the issue names shm_retire_unmapped as the lazy cleanup to revisit. Reproduce the described probe: attach, write W, call munmap, then attach again and read the value. Done means writes persist after unmapping and old-image attaches are dropped at exec.

Written by the indexing model from the issue text.

Description

bug

Follow-up to #485 (review comment r4504029776).

An attach is released only lazily: the next shmat or shmdt retires records whose serial no region carries. Two cases still differ from Linux:

  • After execve, the new image may never call shmat or shmdt, so every attach of the old image keeps its host attach until the process exits. This also keeps an IPC_RMIDed segment alive.
  • When the guest munmaps an attach without shmdt, its writes are lost. On Linux those pages are the segment, so the writes persist.

Measured with a probe that runs shmat, writes W, calls munmap and attaches again: Linux reads W, and elfuse reads 0.

Proposed fix: write back and detach from the sys_munmap path, and write back and drop every record at exec. This would also make the lazy sweep in shm_retire_unmapped unnecessary.

Dominant language
C
Stars
287
Forks
33
Avg merge
2d 17h
Merged PRs (30d)
18

Getting set up

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.

More from sysprog21/elfuse

All issues in sysprog21/elfuse

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.