armv7l: `close`, `unlink` and `chroot` pass the kernel their argument's address

Open Beginner friendly
#136 0 comments 0 reactions 0 assignees View on GitHub

@aoinoikaz is already working on this.

Since Nov 3, 2026.

  • #137 by @aoinoikaz — open

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, linux
Domain
cli

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, unlink and chroot on 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from oriansj/M2libc

All issues in oriansj/M2libc

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.