mmap of non-mappable character devices succeeds

Open
#499 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
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, linux

Research direction

Start by tracing the mmap handling and mmap_refused_errno logic, then compare how character-device and anon-inode file descriptors are classified. The issue gives /dev/null, /dev/urandom, /dev/zero, and several anon-inode descriptors as cases to investigate. Done means the no-limit and over-limit results match Linux for these cases, including ENODEV for devices that cannot be mapped.

Written by the indexing model from the issue text.

Description

mmap of a character device that Linux cannot map succeeds under elfuse. Linux returns ENODEV, because the device's file operations have no mmap.

Measured with a probe, under elfuse at #485 (6fbbc9f) and on Linux:

fd Linux, no limit elfuse, no limit Linux, over RLIMIT_AS elfuse, over RLIMIT_AS
/dev/null ENODEV maps ENODEV ENOMEM
/dev/urandom ENODEV maps ENODEV ENOMEM
/dev/zero maps maps ENOMEM ENOMEM
eventfd, epoll, timerfd, signalfd ENODEV other errno ENODEV ENODEV

"Over RLIMIT_AS" is an 8 GiB MAP_PRIVATE PROT_READ request with the limit at 4 GiB. The probe found two gaps:

  • Character devices: elfuse does not track which ones can be mapped. A fix would decide this per device (for example, allow /dev/zero and refuse the others with ENODEV) on the no-limit path. The over-limit path in mmap_refused_errno would then use the same check.
  • Anon-inode fds: with no limit set, they return a different errno than Linux's ENODEV.

Raised by review on #485 (r4506898326).

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.