`F_GETPIPE_SZ` returns `EINVAL`, and `F_SETLEASE` returns 65536
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c
- Domain
- operating-systems
Research direction
Start in sys_fcntl in src/syscall/fs.c, where the switch uses case 1024 for F_GETPIPE_SZ, and compare its command numbers with Linux's F_LINUX_SPECIFIC_BASE offsets from the issue. Compile the reproducer and run it on a pipe and a regular file. Done when F_GETPIPE_SZ returns the pipe size, F_SETLEASE on a pipe returns EINVAL, and F_SETLEASE on a file returns 0, matching the Linux row in the table.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C
- Stars
- 275
- Forks
- 29
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 18
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/elfuse
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 3 days
-
bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 3 days
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 3 days
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 54/100
Maintainers usually reply within 3 days
All issues in sysprog21/elfuse
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 93/100
webarkit/WebARKitLib#107 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
polhenarejos/pico-fido#302 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
espressif/esp-vision#16 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
libsdl-org/SDL#16577 ·
Maintainers usually reply within 1 day