mprotect changes a whole range instead of stopping at the first failing mapping

Offen
#489 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
c, linux

Rechercherichtung

Start by reading sys_mprotect and the range handling around guest_region_range_has_ro_shared_backing; the issue does not name their source files or tests. Trace how mappings are processed in address order, including holes and RLIMIT_DATA refusals. Done means processing stops at the first failing mapping while earlier changes remain, matching the Linux behavior described in the issue.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

sys_mprotect changes a whole range at once, where Linux's mprotect_fixup takes the mappings in address order and stops at the first one that fails, leaving the mappings below it changed.

On 170b5df, mapping three read-only pages, unmapping the middle one, then mprotect(p, 3 pages, PROT_READ | PROT_WRITE) returns 0 and makes the first and third pages writable. Linux 6.12 returns ENOMEM at the hole, with the first page writable and the third unchanged.

The same whole-range step shows up in the RLIMIT_DATA check from #485: the part of a range below the mapping the limit refuses is changed with one sys_mprotect, so guest_region_range_has_ro_shared_backing refuses that whole part with EACCES before any mapping below the shared one changes, and a hole inside it gets page tables and the new permissions.

A fix would walk the range in address order and stop at the first hole, refused mapping or RLIMIT_DATA refusal.

Vorherrschende Sprache
C
Sterne
287
Forks
33
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
18

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus sysprog21/elfuse

Alle Issues in sysprog21/elfuse

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.