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

Move all seccomp consts and structs into top-level mod #3343

Merged
merged 1 commit into from
Jan 4, 2024
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
24 changes: 24 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3520,6 +3520,19 @@ fn test_linux(target: &str) {
if musl && ty.starts_with("uinput_") {
return true;
}
if musl && ty == "seccomp_notif" {
return true;
}
if musl && ty == "seccomp_notif_addfd" {
return true;
}
if musl && ty == "seccomp_notif_resp" {
return true;
}
if musl && ty == "seccomp_notif_sizes" {
return true;
}

// LFS64 types have been removed in musl 1.2.4+
if musl && (ty.ends_with("64") || ty.ends_with("64_t")) {
return true;
Expand Down Expand Up @@ -3648,6 +3661,17 @@ fn test_linux(target: &str) {
}
}
if musl {
// FIXME: Requires >= 5.0 kernel headers
if name == "SECCOMP_GET_NOTIF_SIZES"
|| name == "SECCOMP_FILTER_FLAG_NEW_LISTENER"
|| name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH"
|| name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5
|| name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9
|| name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9
|| name == "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" // requires >= 5.19
{
return true;
}
// FIXME: Requires >= 5.4.1 kernel headers
if name.starts_with("J1939")
|| name.starts_with("RTEXT_FILTER_")
Expand Down
18 changes: 16 additions & 2 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2373,23 +2373,33 @@ SCTP_STATUS
SCTP_STREAM_RESET_INCOMING
SCTP_STREAM_RESET_OUTGOING
SCTP_UNORDERED
SECCOMP_ADDFD_FLAG_SEND
SECCOMP_ADDFD_FLAG_SETFD
SECCOMP_FILTER_FLAG_LOG
SECCOMP_FILTER_FLAG_NEW_LISTENER
SECCOMP_FILTER_FLAG_SPEC_ALLOW
SECCOMP_FILTER_FLAG_TSYNC
SECCOMP_FILTER_FLAG_TSYNC_ESRCH
SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV
SECCOMP_GET_ACTION_AVAIL
SECCOMP_GET_NOTIF_SIZES
SECCOMP_MODE_DISABLED
SECCOMP_MODE_FILTER
SECCOMP_MODE_STRICT
SECCOMP_MODE_FILTER
SECCOMP_RET_ACTION
SECCOMP_RET_ACTION_FULL
SECCOMP_RET_ALLOW
SECCOMP_RET_DATA
SECCOMP_RET_ERRNO
SECCOMP_RET_KILL
SECCOMP_RET_KILL_PROCESS
SECCOMP_RET_KILL_THREAD
SECCOMP_RET_KILL
SECCOMP_RET_LOG
SECCOMP_RET_TRACE
SECCOMP_RET_TRAP
SECCOMP_SET_MODE_FILTER
SECCOMP_SET_MODE_STRICT
SECCOMP_USER_NOTIF_FLAG_CONTINUE
SEEK_DATA
SEEK_HOLE
SELFMAG
Expand Down Expand Up @@ -3500,6 +3510,10 @@ sched_setparam
sched_setscheduler
sctp_assoc_t
seccomp_data
seccomp_notif
seccomp_notif_addfd
seccomp_notif_resp
seccomp_notif_sizes
seed48
seekdir
sem_close
Expand Down
11 changes: 0 additions & 11 deletions src/unix/linux_like/linux/gnu/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ s! {
pub ss_size: ::size_t
}

pub struct seccomp_notif_sizes {
pub seccomp_notif: ::__u16,
pub seccomp_notif_resp: ::__u16,
pub seccomp_data: ::__u16,
}

pub struct mcontext_t {
pub trap_no: ::c_ulong,
pub error_code: ::c_ulong,
Expand Down Expand Up @@ -466,11 +460,6 @@ pub const B3000000: ::speed_t = 0o010015;
pub const B3500000: ::speed_t = 0o010016;
pub const B4000000: ::speed_t = 0o010017;

pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;

pub const VEOL: usize = 11;
pub const VEOL2: usize = 16;
pub const VMIN: usize = 6;
Expand Down
5 changes: 0 additions & 5 deletions src/unix/linux_like/linux/gnu/b32/csky/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,6 @@ pub const B3000000: ::speed_t = 0o010015;
pub const B3500000: ::speed_t = 0o010016;
pub const B4000000: ::speed_t = 0o010017;

pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;

pub const VEOL: usize = 11;
pub const VEOL2: usize = 16;
pub const VMIN: usize = 6;
Expand Down
10 changes: 0 additions & 10 deletions src/unix/linux_like/linux/gnu/b32/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ s! {
pub ss_size: ::size_t
}

pub struct seccomp_notif_sizes {
pub seccomp_notif: ::__u16,
pub seccomp_notif_resp: ::__u16,
pub seccomp_data: ::__u16,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1090,11 +1085,6 @@ pub const REG_EFL: ::c_int = 16;
pub const REG_UESP: ::c_int = 17;
pub const REG_SS: ::c_int = 18;

pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;

extern "C" {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
Expand Down
10 changes: 0 additions & 10 deletions src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ s! {
pub ss_size: ::size_t
}

pub struct seccomp_notif_sizes {
pub seccomp_notif: ::__u16,
pub seccomp_notif_resp: ::__u16,
pub seccomp_data: ::__u16,
}
}

pub const VEOF: usize = 4;
Expand Down Expand Up @@ -513,11 +508,6 @@ pub const B3000000: ::speed_t = 0o010015;
pub const B3500000: ::speed_t = 0o010016;
pub const B4000000: ::speed_t = 0o010017;

pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;

pub const VEOL: usize = 11;
pub const VEOL2: usize = 16;
pub const VMIN: usize = 6;
Expand Down
11 changes: 0 additions & 11 deletions src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ s! {
__unused5: u64
}

pub struct seccomp_notif_sizes {
pub seccomp_notif: ::__u16,
pub seccomp_notif_resp: ::__u16,
pub seccomp_data: ::__u16,
}

pub struct ptrace_rseq_configuration {
pub rseq_abi_pointer: ::__u64,
pub rseq_abi_size: ::__u32,
Expand Down Expand Up @@ -803,11 +797,6 @@ pub const REG_TRAPNO: ::c_int = 20;
pub const REG_OLDMASK: ::c_int = 21;
pub const REG_CR2: ::c_int = 22;

pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;

extern "C" {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
Expand Down
42 changes: 42 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,34 @@ s! {
pub args: [::__u64; 6],
}

pub struct seccomp_notif_sizes {
pub seccomp_notif: ::__u16,
pub seccomp_notif_resp: ::__u16,
pub seccomp_data: ::__u16,
}

pub struct seccomp_notif {
pub id: ::__u64,
pub pid: ::__u32,
pub flags: ::__u32,
pub data: seccomp_data,
}

pub struct seccomp_notif_resp {
pub id: ::__u64,
pub val: ::__s64,
pub error: ::__s32,
pub flags: ::__u32,
}

pub struct seccomp_notif_addfd {
pub id: ::__u64,
pub flags: ::__u32,
pub srcfd: ::__u32,
pub newfd: ::__u32,
pub newfd_flags: ::__u32,
}

pub struct nlmsghdr {
pub nlmsg_len: u32,
pub nlmsg_type: u16,
Expand Down Expand Up @@ -2272,13 +2300,22 @@ pub const GRND_NONBLOCK: ::c_uint = 0x0001;
pub const GRND_RANDOM: ::c_uint = 0x0002;
pub const GRND_INSECURE: ::c_uint = 0x0004;

// <linux/seccomp.h>
pub const SECCOMP_MODE_DISABLED: ::c_uint = 0;
pub const SECCOMP_MODE_STRICT: ::c_uint = 1;
pub const SECCOMP_MODE_FILTER: ::c_uint = 2;

pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;

pub const SECCOMP_FILTER_FLAG_TSYNC: ::c_ulong = 1;
pub const SECCOMP_FILTER_FLAG_LOG: ::c_ulong = 2;
pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: ::c_ulong = 4;
pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: ::c_ulong = 8;
pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: ::c_ulong = 16;
pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: ::c_ulong = 32;

pub const SECCOMP_RET_KILL_PROCESS: ::c_uint = 0x80000000;
pub const SECCOMP_RET_KILL_THREAD: ::c_uint = 0x00000000;
Expand All @@ -2293,6 +2330,11 @@ pub const SECCOMP_RET_ACTION_FULL: ::c_uint = 0xffff0000;
pub const SECCOMP_RET_ACTION: ::c_uint = 0x7fff0000;
pub const SECCOMP_RET_DATA: ::c_uint = 0x0000ffff;

pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: ::c_ulong = 1;

pub const SECCOMP_ADDFD_FLAG_SETFD: ::c_ulong = 1;
pub const SECCOMP_ADDFD_FLAG_SEND: ::c_ulong = 2;

pub const ITIMER_REAL: ::c_int = 0;
pub const ITIMER_VIRTUAL: ::c_int = 1;
pub const ITIMER_PROF: ::c_int = 2;
Expand Down