Skip to content

Commit

Permalink
Move all seccomp consts and structs into top-level mod
Browse files Browse the repository at this point in the history
Seccomp constants and structs were partially defined in the top-level
mod.rs for linux and partially outside. This commit moves everything
into the top-level mod and adds missing entries as of linux 6.4.12.

Signed-off-by: Harry Stern <[email protected]>
  • Loading branch information
boustrophedon committed Sep 7, 2023
1 parent 8356615 commit dd6e53d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 49 deletions.
18 changes: 16 additions & 2 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2317,23 +2317,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 @@ -3413,6 +3423,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 @@ -465,11 +459,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 @@ -414,11 +414,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 @@ -1089,11 +1084,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 @@ -512,11 +507,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 @@ -802,11 +796,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 @@ -577,6 +577,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 @@ -2187,13 +2215,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 @@ -2208,6 +2245,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

0 comments on commit dd6e53d

Please sign in to comment.