armv7l: `close`, `unlink` and `chroot` pass the kernel their argument's address
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The three wrappers close, unlink and chroot are in armv7l/linux/unistd.c, and close also appears in armv7l/linux/bootstrap.c; compare them with chdir and fchdir in the same file, which already load the argument with !0 R0 LOAD32 R0 MEMORY. Apply that load after the first line of each broken function, then confirm the fix with the armv7l qemu-user run described in the issue. Done when close, unlink and chroot pass the argument itself to the kernel on armv7l, matching x86 results.
Written by the indexing model from the issue text.
Description
On armv7l, close (unistd.c#L123-L128), unlink (#L131-L136) and chroot (#L218-L223) in armv7l/linux/unistd.c, and close in armv7l/linux/bootstrap.c (#L52-L57), compute the address of their first argument with !4 R0 SUB R12 ARITH_ALWAYS and pass that address to the syscall. chdir and fchdir (#L36-L50) follow it with !0 R0 LOAD32 R0 MEMORY, which loads the argument itself; these three do not.
So close closes nothing, unlink removes nothing, and chroot is given the wrong path. Built with M2-Planet at ebfecc2 against this tree and run on x86 and on armv7l under qemu-user (run):
| x86 | armv7l | |
|---|---|---|
close(fd) |
0 | -9 (EBADF) |
fd from the next open |
3 | 4 |
unlink(file) |
0 | -2 (ENOENT), the file stays |
chroot("/") |
-1 (EPERM) | -2 (ENOENT) |
Fix: add !0 R0 LOAD32 R0 MEMORY after the first line of each.
Done when:
-
close,unlinkandchrooton armv7l pass the kernel their argument
- Dominant language
- C
- Stars
- 27
- Forks
- 20
- Avg merge
- 5d 12h
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 oriansj/M2libc
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
`fseek` returns the new position instead of 0Possibly taken @aoinoikaz claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
good first issue
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 4 days
-
area/docs
Difficulty 1/5 Under an hour Newbie friendliness 83/100
Clodmony/starship-coop#72 ·
Maintainers usually reply within 1 day
-
ospf6d: heap-use-after-free in seqnumber_mismatch()/bad_lsreq() when a neighbor is deleted with events pendingPossibly taken @lichenlang89 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
Maintainers usually reply within 2 days
-
5700模组网络优先级问题Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day