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

`F_GETPIPE_SZ` returns `EINVAL`, and `F_SETLEASE` returns 65536

Aperta Adatta ai principianti
#422 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Parti da sys_fcntl in src/syscall/fs.c, dove lo switch usa case 1024 per F_GETPIPE_SZ, e confronta i suoi numeri di comando con gli offset F_LINUX_SPECIFIC_BASE di Linux indicati nell'issue. Compila il reproducer ed eseguilo su una pipe e su un file regolare. Il lavoro è completo quando F_GETPIPE_SZ restituisce la dimensione della pipe, F_SETLEASE su una pipe restituisce EINVAL e F_SETLEASE su un file restituisce 0, in linea con la riga Linux della tabella.

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

Descrizione

bug

sys_fcntl (src/syscall/fs.c) answers F_GETPIPE_SZ under case 1024. Linux counts these commands from F_LINUX_SPECIFIC_BASE, which is 1024: F_SETLEASE is 1024, F_GETLEASE is 1025, F_SETPIPE_SZ is 1031 and F_GETPIPE_SZ is 1032. The real F_GETPIPE_SZ therefore reaches the default arm and returns EINVAL, and F_SETLEASE returns 65536 on any fd, which its caller reads as success.

Reproducer:

#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
{
    int p[2];
    pipe(p);
    int file = open("/tmp/lease-file", O_CREAT | O_RDONLY, 0600);

    errno = 0;
    printf("F_GETPIPE_SZ on a pipe: %d errno=%d\n", fcntl(p[0], F_GETPIPE_SZ),
           errno);
    errno = 0;
    printf("F_SETLEASE on a pipe:   %d errno=%d\n",
           fcntl(p[0], F_SETLEASE, F_RDLCK), errno);
    errno = 0;
    printf("F_SETLEASE on a file:   %d errno=%d\n",
           fcntl(file, F_SETLEASE, F_RDLCK), errno);
    unlink("/tmp/lease-file");
    return 0;
}
F_GETPIPE_SZ on a pipe F_SETLEASE on a pipe F_SETLEASE on a file
elfuse b57f367 -1, EINVAL 65536 65536
Linux 6.12 under qemu 65536 -1, EINVAL 0

F_SETPIPE_SZ is under the right number. It returns its argument and leaves the host pipe as it is, which the comment beside it says.

Lingua principale
C
Stelle
273
Fork
29
Merge medio
2g 17h
PR unite (30g)
17

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.