Skip to content

Add SYS_pidfd_open and SYS_clone3 #1897

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,13 @@ fn test_linux(target: &str) {
// headers.
"P_PIDFD" => true,

// FIXME: Not currently available in headers
"SYS_pidfd_open" if mips => true,

// FIXME: Not currently available in headers on MIPS
// Not yet implemented on sparc64
"SYS_clone3" if mips | sparc64 => true,

_ => false,
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ pub const SYS_pkey_mprotect: ::c_long = 394;
pub const SYS_pkey_alloc: ::c_long = 395;
pub const SYS_pkey_free: ::c_long = 396;
pub const SYS_statx: ::c_long = 397;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;

cfg_if! {
if #[cfg(libc_align)] {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ pub const SYS_pkey_mprotect: ::c_long = 4000 + 363;
pub const SYS_pkey_alloc: ::c_long = 4000 + 364;
pub const SYS_pkey_free: ::c_long = 4000 + 365;
pub const SYS_statx: ::c_long = 4000 + 366;
pub const SYS_pidfd_open: ::c_long = 4000 + 434;
pub const SYS_clone3: ::c_long = 4000 + 435;

pub const O_DIRECT: ::c_int = 0x8000;
pub const O_DIRECTORY: ::c_int = 0x10000;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,3 +872,5 @@ pub const SYS_preadv2: ::c_long = 380;
pub const SYS_pwritev2: ::c_long = 381;
pub const SYS_kexec_file_load: ::c_long = 382;
pub const SYS_statx: ::c_long = 383;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;
3 changes: 3 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,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;

#[link(name = "util")]
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b32/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,8 @@ pub const SYS_pkey_mprotect: ::c_long = 380;
pub const SYS_pkey_alloc: ::c_long = 381;
pub const SYS_pkey_free: ::c_long = 382;
pub const SYS_statx: ::c_long = 383;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;

// offsets in user_regs_structs, from sys/reg.h
pub const EBX: ::c_int = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ pub const SYS_pkey_mprotect: ::c_long = 288;
pub const SYS_pkey_alloc: ::c_long = 289;
pub const SYS_pkey_free: ::c_long = 290;
pub const SYS_statx: ::c_long = 291;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;

#[link(name = "util")]
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/mips64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ pub const SYS_pkey_mprotect: ::c_long = 5000 + 323;
pub const SYS_pkey_alloc: ::c_long = 5000 + 324;
pub const SYS_pkey_free: ::c_long = 5000 + 325;
pub const SYS_statx: ::c_long = 5000 + 326;
pub const SYS_pidfd_open: ::c_long = 5000 + 434;
pub const SYS_clone3: ::c_long = 5000 + 435;

pub const SFD_CLOEXEC: ::c_int = 0x080000;

Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ pub const SYS_preadv2: ::c_long = 380;
pub const SYS_pwritev2: ::c_long = 381;
pub const SYS_kexec_file_load: ::c_long = 382;
pub const SYS_statx: ::c_long = 383;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;

#[link(name = "util")]
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,3 +857,5 @@ pub const SYS_pkey_mprotect: ::c_long = 288;
pub const SYS_pkey_alloc: ::c_long = 289;
pub const SYS_pkey_free: ::c_long = 290;
pub const SYS_statx: ::c_long = 291;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ pub const SYS_setfsuid: ::c_long = 215;
pub const SYS_setfsgid: ::c_long = 216;
pub const SYS_newfstatat: ::c_long = 293;
pub const SYS_statx: ::c_long = 379;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;

#[link(name = "util")]
extern "C" {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.


#[link(name = "util")]
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ pub const SYS_pkey_mprotect: ::c_long = 329;
pub const SYS_pkey_alloc: ::c_long = 330;
pub const SYS_pkey_free: ::c_long = 331;
pub const SYS_statx: ::c_long = 332;
pub const SYS_pidfd_open: ::c_long = 434;
pub const SYS_clone3: ::c_long = 435;

#[link(name = "util")]
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ pub const SYS_pkey_mprotect: ::c_long = __X32_SYSCALL_BIT + 329;
pub const SYS_pkey_alloc: ::c_long = __X32_SYSCALL_BIT + 330;
pub const SYS_pkey_free: ::c_long = __X32_SYSCALL_BIT + 331;
pub const SYS_statx: ::c_long = __X32_SYSCALL_BIT + 332;
pub const SYS_pidfd_open: ::c_long = __X32_SYSCALL_BIT + 434;
pub const SYS_clone3: ::c_long = __X32_SYSCALL_BIT + 435;
pub const SYS_rt_sigaction: ::c_long = __X32_SYSCALL_BIT + 512;
pub const SYS_rt_sigreturn: ::c_long = __X32_SYSCALL_BIT + 513;
pub const SYS_ioctl: ::c_long = __X32_SYSCALL_BIT + 514;
Expand Down