shmat ignores shmaddr

Open
#502 1 comment 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
57/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, linux, macos

Research direction

Start in src/syscall/sysvipc.c at sys_shmat, where shmaddr_gva is currently ignored, and inspect how address mapping and the SHM_RND and SHM_REMAP flags are handled. Read steps 26–28 of test-rlimit-mem, which currently skip when the attach lands elsewhere. Done means the requested address and documented error cases are honored, with those test steps checking the chosen address strictly.

Written by the indexing model from the issue text.

Description

sys_shmat ignores shmaddr ((void) shmaddr_gva in src/syscall/sysvipc.c): every attach goes wherever the allocator puts it. Linux attaches at shmaddr when it is given, rounding it down with SHM_RND, and replaces what is mapped there with SHM_REMAP. It fails with EINVAL when the address is unaligned without SHM_RND, or when the range is already mapped and SHM_REMAP is not set.

A program that attaches at a chosen address, for example to share pointers between processes, gets a different address under elfuse.

Found in review on #485 (r4510389312). Steps 26 to 28 of test-rlimit-mem attach into a hole they just unmapped, and skip when the attach lands elsewhere. Once shmat honors the address, those steps can go back to a strict check.

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.