Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SYS_pidfd_open and SYS_clone3 #1897

Merged

Conversation

Aaron1011
Copy link
Member

These syscalls were added recently, and therefore have consistent
numbers across different architetures (other than the weird offsetting
on some platforms).

@rust-highfive
Copy link

r? @JohnTitor

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link

@brauner brauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! :)

@@ -973,6 +973,9 @@ pub const SYS_copy_file_range: ::c_long = 357;
pub const SYS_preadv2: ::c_long = 358;
pub const SYS_pwritev2: ::c_long = 359;
pub const SYS_statx: ::c_long = 360;
pub const SYS_pidfd_open: ::c_long = 434;
// Reserved in the kernel, but not actually implemented yet
pub const SYS_clone3: ::c_long = 435;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, but this is fine since I marked 435 as reserved for all architectures that do not implement clone3() yet and so you're guaranteed that we don't take that number for another system call!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're in the process of updating our kernel docs where @cyphar and I will add a line like:

+In the past, syscall numbers were completely inconsistent
+between architectures, but a lot of work has gone into trying to unify the
+syscall tables. If you do not wish to enable your syscall on all architectures,
+add a comment to all other architectures' syscall tables to make it clear that
+the number has been reserved for your syscall.

@cyphar
Copy link

cyphar commented Sep 17, 2020

Can you also add SYS_openat2? 😄

@brauner
Copy link

brauner commented Sep 17, 2020

Can you also add SYS_openat2?

Indeed. The ones up until 5.8 that are missing are:

424     common  pidfd_send_signal       sys_pidfd_send_signal
425     common  io_uring_setup          sys_io_uring_setup
426     common  io_uring_enter          sys_io_uring_enter
427     common  io_uring_register       sys_io_uring_register
428     common  open_tree               sys_open_tree
429     common  move_mount              sys_move_mount
430     common  fsopen                  sys_fsopen
431     common  fsconfig                sys_fsconfig
432     common  fsmount                 sys_fsmount
433     common  fspick                  sys_fspick
434     common  pidfd_open              sys_pidfd_open
435     common  clone3                  sys_clone3
436     common  close_range             sys_close_range
437     common  openat2                 sys_openat2
438     common  pidfd_getfd             sys_pidfd_getfd

These syscalls were added recently, and therefore have consistent
numbers across different architetures (other than the weird offsetting
on some platforms).
@cyphar
Copy link

cyphar commented Sep 17, 2020

close_range is only in 5.9, no? I skipped over 436 when I added openat2 because someone said they were going to submit another syscall in 5.6 that would use it. Also faccessat2 was also available in 5.8.

@brauner
Copy link

brauner commented Sep 17, 2020

close_range is only in 5.9, no? I skipped over 436 when I added openat2 because someone said they were going to submit another syscall in 5.6 that would use it. Also faccessat2 was also available in 5.8.

Ah yeah, I got close_range() merged for v5.9-rc1. :D

@Aaron1011
Copy link
Member Author

@JohnTitor: Would you prefer separate PRs for additional syscall numbers like SYS_openat2, or should I add them all in one PR?

@joshtriplett
Copy link
Member

I'd really like to have these constants available as well.

@JohnTitor
Copy link
Member

@JohnTitor: Would you prefer separate PRs for additional syscall numbers like SYS_openat2, or should I add them all in one PR?

I don't mind either way! I'll wait for a few days if you want to add them, but I'll just merge this if you want to use the items added by this PR as soon as possible.

@joshtriplett
Copy link
Member

Closing and reopening to kick CI and doublecheck this.

@joshtriplett
Copy link
Member

I'm going to go ahead and merge this, since further additions can easily happen via further PRs, and since there's active work going on in rust-lang/rust that may end up using this.

@joshtriplett joshtriplett merged commit 3e9945e into rust-lang:master Oct 1, 2020
bors added a commit that referenced this pull request Mar 16, 2021
Add more syscall constansts for Linux

In #1897 (comment), there was interest in adding constants for recently added Linux syscalls. I went ahead and added consts for syscalls up until (the currently unreleased) Linux 5.12. Here is an overview:

| Syscall           | NR  | since |
| ----------------- | --- | ----- |
| pidfd_send_signal | 424 | 5.1   |
| io_uring_setup    | 425 | 5.1   |
| io_uring_enter    | 426 | 5.1   |
| io_uring_register | 427 | 5.1   |
| open_tree         | 428 | 5.2   |
| move_mount        | 429 | 5.2   |
| fsopen            | 430 | 5.2   |
| fsconfig          | 431 | 5.2   |
| fsmount           | 432 | 5.2   |
| fspick            | 433 | 5.2   |
| pidfd_open        | 434 | 5.3   |
| clone3            | 435 | 5.3   |
| close_range       | 436 | 5.9   |
| openat2           | 437 | 5.9   |
| pidfd_getfd       | 438 | 5.9   |
| faccessat2        | 439 | 5.9   |
| process_madvise   | 440 | 5.10  |
| epoll_pwait2      | 441 | 5.11  |
| mount_setattr     | 442 | 5.12  |

([source](https://github.com/torvalds/linux/blob/1e28eed17697bcf343c6743f0028cc3b5dd88bf0/include/uapi/asm-generic/unistd.h#L825-L865))

The constants are added for `-gnu` and `-musl` targets.
I'm unsure to what extend they are actually present in the headers of these libraries.

Support is added for all architectures except hexagon.
bors added a commit that referenced this pull request Mar 16, 2021
Add more syscall constansts for Linux

In #1897 (comment), there was interest in adding constants for recently added Linux syscalls. I went ahead and added consts for syscalls up until (the currently unreleased) Linux 5.12. Here is an overview:

| Syscall           | NR  | since |
| ----------------- | --- | ----- |
| pidfd_send_signal | 424 | 5.1   |
| io_uring_setup    | 425 | 5.1   |
| io_uring_enter    | 426 | 5.1   |
| io_uring_register | 427 | 5.1   |
| open_tree         | 428 | 5.2   |
| move_mount        | 429 | 5.2   |
| fsopen            | 430 | 5.2   |
| fsconfig          | 431 | 5.2   |
| fsmount           | 432 | 5.2   |
| fspick            | 433 | 5.2   |
| pidfd_open        | 434 | 5.3   |
| clone3            | 435 | 5.3   |
| close_range       | 436 | 5.9   |
| openat2           | 437 | 5.9   |
| pidfd_getfd       | 438 | 5.9   |
| faccessat2        | 439 | 5.9   |
| process_madvise   | 440 | 5.10  |
| epoll_pwait2      | 441 | 5.11  |
| mount_setattr     | 442 | 5.12  |

([source](https://github.com/torvalds/linux/blob/1e28eed17697bcf343c6743f0028cc3b5dd88bf0/include/uapi/asm-generic/unistd.h#L825-L865))

The constants are added for `-gnu` and `-musl` targets.
I'm unsure to what extend they are actually present in the headers of these libraries.

Support is added for all architectures except hexagon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants