Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

fallocate on a read-only descriptor does not fail with EBADF

Aperta
#462 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@xalestar ci sta già lavorando.

Dal 23/10/2026.

  • #463 di @xalestar — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, linux

Direzione di ricerca

Start with sys_fallocate in src/syscall/io.c and the aarch64 probe described in the issue. Compare the access-mode check order with Linux vfs_fallocate and run the probe for both ranges on an O_RDONLY descriptor. Done when every supported mode returns EBADF before checking file size, matching the reference kernel.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Background

vfs_fallocate (Linux fs/open.c) refuses a descriptor that is not open for writing with EBADF, after the offset, length and mode checks and before it looks at the file size. elfuse's sys_fallocate (src/syscall/io.c:3465 on e9fdbbb) never checks the access mode. For mode 0 it calls host ftruncate only when the request grows the file, so a read-only descriptor gets one of two wrong answers:

fallocate(fd, 0, off, len) on an O_RDONLY fd, file size 200 Linux elfuse
grows the file (0, 400) -1, EBADF -1, EINVAL (from host ftruncate)
stays within the file (0, 100) -1, EBADF 0

The second row reports success for a call Linux refuses.

Goal

fallocate on a descriptor not open for writing fails with EBADF in every mode elfuse supports, ahead of any size check, as on Linux.

Evidence

A static aarch64 probe creates a 200-byte file, reopens it O_RDONLY and calls fallocate with the two ranges above. elfuse built from e9fdbbb gives the elfuse column, and the qemu reference kernel used by make test-matrix-qemu-aarch64 gives the Linux column.

Found while adding RLIMIT_FSIZE enforcement (#448 follow-up 1): the new test-rlimit-fsize only checks that the call fails there without SIGXFSZ, not which errno it returns.

Lingua principale
C
Stelle
275
Fork
29
Merge medio
2g 22h
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sysprog21/elfuse

Tutte le issue di sysprog21/elfuse

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.