Odin icon indicating copy to clipboard operation
Odin copied to clipboard

[sys/linux] Fix fork and execve syscalls on arm64

Open PucklaJ opened this issue 1 year ago • 4 comments

This PR does the following things:

  • Adds flag parameter to execveat syscall
  • Adds clone syscall
  • Uses execveat procedure in execve syscall on arm64
  • Uses clone procedure in fork syscall on arm64

Fixes #3472 Fixes #3487

The syscalls have been implemented based on the ChromiumOS docs

PucklaJ avatar Apr 24 '24 13:04 PucklaJ

Is there a particular reason as to why the execve syscall is not used on arm64? It does exist and run completely fine on my Pinebook Pro. I considered changing the execveat syscall to execve on arm64 in the execve procedure.

PucklaJ avatar Apr 28 '24 10:04 PucklaJ

Is there a particular reason as to why the execve syscall is not used on arm64? It does exist and run completely fine on my Pinebook Pro. I considered changing the execveat syscall to execve on arm64 in the execve procedure.

I believe this one may have been assumed =] It's not uncommon for arm64 to only have the *at version of the syscall. I wonder if we should just use the *at functions for everything as it would get rid of all the when business. Everyone has those functions. Here is the entirety of the difference between open and openat in the Linux source code:

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
{
        if (force_o_largefile())
                flags |= O_LARGEFILE;
        return do_sys_open(AT_FDCWD, filename, flags, mode);
}

SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
                umode_t, mode)
{
        if (force_o_largefile())
                flags |= O_LARGEFILE;
        return do_sys_open(dfd, filename, flags, mode);
}

jasonKercher avatar Apr 28 '24 11:04 jasonKercher

@flysand7 I made the requested changes. Is there still something that needs to be changed?

PucklaJ avatar May 23 '24 11:05 PucklaJ

@gingerBill looks good to merge

flysand7 avatar Jun 01 '24 23:06 flysand7

@flysand7 What should that type be in the conflict?

gingerBill avatar Jul 04 '24 22:07 gingerBill

@gingerBill I can't see what the conflict is, so... no idea

flysand7 avatar Jul 14 '24 04:07 flysand7

Execve_Flags does not exist. Should I create a bit_set that uses FD_Flags_Bits?

PucklaJ avatar Jul 20 '24 10:07 PucklaJ

https://github.com/odin-lang/Odin/pull/3476/files#diff-988793090a86cbbc5126181f239031996412c074c814e90738c6aa08e57b5d25R1310

flysand7 avatar Jul 20 '24 10:07 flysand7

@flysand7 done

PucklaJ avatar Jul 22 '24 09:07 PucklaJ