Skip to content

Commit d3238e0

Browse files
committed
Auto merge of #3343 - boustrophedon:seccomp_uniform, r=JohnTitor
Move all seccomp consts and structs into top-level mod Move all seccomp consts and structs into top-level mod 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. Resolves #3342 and [rust-vmm/seccompiler#57](rust-vmm/seccompiler#57) I couldn't get main to run libc-test cargo test (even without my changes) with either gcc 13.2.1 or clang 16.0.6. They failed with different errors/warnings.
2 parents ee1551a + 466516d commit d3238e0

File tree

8 files changed

+82
-49
lines changed

8 files changed

+82
-49
lines changed

libc-test/build.rs

+24
Original file line numberDiff line numberDiff line change
@@ -3574,6 +3574,19 @@ fn test_linux(target: &str) {
35743574
if musl && ty.starts_with("uinput_") {
35753575
return true;
35763576
}
3577+
if musl && ty == "seccomp_notif" {
3578+
return true;
3579+
}
3580+
if musl && ty == "seccomp_notif_addfd" {
3581+
return true;
3582+
}
3583+
if musl && ty == "seccomp_notif_resp" {
3584+
return true;
3585+
}
3586+
if musl && ty == "seccomp_notif_sizes" {
3587+
return true;
3588+
}
3589+
35773590
// LFS64 types have been removed in musl 1.2.4+
35783591
if musl && (ty.ends_with("64") || ty.ends_with("64_t")) {
35793592
return true;
@@ -3726,6 +3739,17 @@ fn test_linux(target: &str) {
37263739
}
37273740
}
37283741
if musl {
3742+
// FIXME: Requires >= 5.0 kernel headers
3743+
if name == "SECCOMP_GET_NOTIF_SIZES"
3744+
|| name == "SECCOMP_FILTER_FLAG_NEW_LISTENER"
3745+
|| name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH"
3746+
|| name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5
3747+
|| name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9
3748+
|| name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9
3749+
|| name == "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" // requires >= 5.19
3750+
{
3751+
return true;
3752+
}
37293753
// FIXME: Requires >= 5.4.1 kernel headers
37303754
if name.starts_with("J1939")
37313755
|| name.starts_with("RTEXT_FILTER_")

libc-test/semver/linux.txt

+16-2
Original file line numberDiff line numberDiff line change
@@ -2383,23 +2383,33 @@ SCTP_STATUS
23832383
SCTP_STREAM_RESET_INCOMING
23842384
SCTP_STREAM_RESET_OUTGOING
23852385
SCTP_UNORDERED
2386+
SECCOMP_ADDFD_FLAG_SEND
2387+
SECCOMP_ADDFD_FLAG_SETFD
23862388
SECCOMP_FILTER_FLAG_LOG
2389+
SECCOMP_FILTER_FLAG_NEW_LISTENER
23872390
SECCOMP_FILTER_FLAG_SPEC_ALLOW
23882391
SECCOMP_FILTER_FLAG_TSYNC
2392+
SECCOMP_FILTER_FLAG_TSYNC_ESRCH
2393+
SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV
2394+
SECCOMP_GET_ACTION_AVAIL
2395+
SECCOMP_GET_NOTIF_SIZES
23892396
SECCOMP_MODE_DISABLED
2390-
SECCOMP_MODE_FILTER
23912397
SECCOMP_MODE_STRICT
2398+
SECCOMP_MODE_FILTER
23922399
SECCOMP_RET_ACTION
23932400
SECCOMP_RET_ACTION_FULL
23942401
SECCOMP_RET_ALLOW
23952402
SECCOMP_RET_DATA
23962403
SECCOMP_RET_ERRNO
2397-
SECCOMP_RET_KILL
23982404
SECCOMP_RET_KILL_PROCESS
23992405
SECCOMP_RET_KILL_THREAD
2406+
SECCOMP_RET_KILL
24002407
SECCOMP_RET_LOG
24012408
SECCOMP_RET_TRACE
24022409
SECCOMP_RET_TRAP
2410+
SECCOMP_SET_MODE_FILTER
2411+
SECCOMP_SET_MODE_STRICT
2412+
SECCOMP_USER_NOTIF_FLAG_CONTINUE
24032413
SEEK_DATA
24042414
SEEK_HOLE
24052415
SELFMAG
@@ -3748,6 +3758,10 @@ sched_setparam
37483758
sched_setscheduler
37493759
sctp_assoc_t
37503760
seccomp_data
3761+
seccomp_notif
3762+
seccomp_notif_addfd
3763+
seccomp_notif_resp
3764+
seccomp_notif_sizes
37513765
seed48
37523766
seekdir
37533767
sem_close

src/unix/linux_like/linux/gnu/b32/arm/mod.rs

-11
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,6 @@ s! {
162162
pub ss_size: ::size_t
163163
}
164164

165-
pub struct seccomp_notif_sizes {
166-
pub seccomp_notif: ::__u16,
167-
pub seccomp_notif_resp: ::__u16,
168-
pub seccomp_data: ::__u16,
169-
}
170-
171165
pub struct mcontext_t {
172166
pub trap_no: ::c_ulong,
173167
pub error_code: ::c_ulong,
@@ -466,11 +460,6 @@ pub const B3000000: ::speed_t = 0o010015;
466460
pub const B3500000: ::speed_t = 0o010016;
467461
pub const B4000000: ::speed_t = 0o010017;
468462

469-
pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
470-
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
471-
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
472-
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;
473-
474463
pub const VEOL: usize = 11;
475464
pub const VEOL2: usize = 16;
476465
pub const VMIN: usize = 6;

src/unix/linux_like/linux/gnu/b32/csky/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,6 @@ pub const B3000000: ::speed_t = 0o010015;
415415
pub const B3500000: ::speed_t = 0o010016;
416416
pub const B4000000: ::speed_t = 0o010017;
417417

418-
pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
419-
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
420-
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
421-
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;
422-
423418
pub const VEOL: usize = 11;
424419
pub const VEOL2: usize = 16;
425420
pub const VMIN: usize = 6;

src/unix/linux_like/linux/gnu/b32/x86/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ s! {
236236
pub ss_size: ::size_t
237237
}
238238

239-
pub struct seccomp_notif_sizes {
240-
pub seccomp_notif: ::__u16,
241-
pub seccomp_notif_resp: ::__u16,
242-
pub seccomp_data: ::__u16,
243-
}
244239
}
245240

246241
s_no_extra_traits! {
@@ -1090,11 +1085,6 @@ pub const REG_EFL: ::c_int = 16;
10901085
pub const REG_UESP: ::c_int = 17;
10911086
pub const REG_SS: ::c_int = 18;
10921087

1093-
pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
1094-
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
1095-
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
1096-
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;
1097-
10981088
extern "C" {
10991089
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
11001090
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;

src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,6 @@ s! {
197197
pub ss_size: ::size_t
198198
}
199199

200-
pub struct seccomp_notif_sizes {
201-
pub seccomp_notif: ::__u16,
202-
pub seccomp_notif_resp: ::__u16,
203-
pub seccomp_data: ::__u16,
204-
}
205200
}
206201

207202
pub const VEOF: usize = 4;
@@ -513,11 +508,6 @@ pub const B3000000: ::speed_t = 0o010015;
513508
pub const B3500000: ::speed_t = 0o010016;
514509
pub const B4000000: ::speed_t = 0o010017;
515510

516-
pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
517-
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
518-
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
519-
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;
520-
521511
pub const VEOL: usize = 11;
522512
pub const VEOL2: usize = 16;
523513
pub const VMIN: usize = 6;

src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs

-11
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,6 @@ s! {
260260
__unused5: u64
261261
}
262262

263-
pub struct seccomp_notif_sizes {
264-
pub seccomp_notif: ::__u16,
265-
pub seccomp_notif_resp: ::__u16,
266-
pub seccomp_data: ::__u16,
267-
}
268-
269263
pub struct ptrace_rseq_configuration {
270264
pub rseq_abi_pointer: ::__u64,
271265
pub rseq_abi_size: ::__u32,
@@ -803,11 +797,6 @@ pub const REG_TRAPNO: ::c_int = 20;
803797
pub const REG_OLDMASK: ::c_int = 21;
804798
pub const REG_CR2: ::c_int = 22;
805799

806-
pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
807-
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
808-
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
809-
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;
810-
811800
extern "C" {
812801
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
813802
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;

src/unix/linux_like/linux/mod.rs

+42
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,34 @@ s! {
575575
pub args: [::__u64; 6],
576576
}
577577

578+
pub struct seccomp_notif_sizes {
579+
pub seccomp_notif: ::__u16,
580+
pub seccomp_notif_resp: ::__u16,
581+
pub seccomp_data: ::__u16,
582+
}
583+
584+
pub struct seccomp_notif {
585+
pub id: ::__u64,
586+
pub pid: ::__u32,
587+
pub flags: ::__u32,
588+
pub data: seccomp_data,
589+
}
590+
591+
pub struct seccomp_notif_resp {
592+
pub id: ::__u64,
593+
pub val: ::__s64,
594+
pub error: ::__s32,
595+
pub flags: ::__u32,
596+
}
597+
598+
pub struct seccomp_notif_addfd {
599+
pub id: ::__u64,
600+
pub flags: ::__u32,
601+
pub srcfd: ::__u32,
602+
pub newfd: ::__u32,
603+
pub newfd_flags: ::__u32,
604+
}
605+
578606
pub struct nlmsghdr {
579607
pub nlmsg_len: u32,
580608
pub nlmsg_type: u16,
@@ -2272,13 +2300,22 @@ pub const GRND_NONBLOCK: ::c_uint = 0x0001;
22722300
pub const GRND_RANDOM: ::c_uint = 0x0002;
22732301
pub const GRND_INSECURE: ::c_uint = 0x0004;
22742302

2303+
// <linux/seccomp.h>
22752304
pub const SECCOMP_MODE_DISABLED: ::c_uint = 0;
22762305
pub const SECCOMP_MODE_STRICT: ::c_uint = 1;
22772306
pub const SECCOMP_MODE_FILTER: ::c_uint = 2;
22782307

2308+
pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0;
2309+
pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1;
2310+
pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2;
2311+
pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3;
2312+
22792313
pub const SECCOMP_FILTER_FLAG_TSYNC: ::c_ulong = 1;
22802314
pub const SECCOMP_FILTER_FLAG_LOG: ::c_ulong = 2;
22812315
pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: ::c_ulong = 4;
2316+
pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: ::c_ulong = 8;
2317+
pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: ::c_ulong = 16;
2318+
pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: ::c_ulong = 32;
22822319

22832320
pub const SECCOMP_RET_KILL_PROCESS: ::c_uint = 0x80000000;
22842321
pub const SECCOMP_RET_KILL_THREAD: ::c_uint = 0x00000000;
@@ -2293,6 +2330,11 @@ pub const SECCOMP_RET_ACTION_FULL: ::c_uint = 0xffff0000;
22932330
pub const SECCOMP_RET_ACTION: ::c_uint = 0x7fff0000;
22942331
pub const SECCOMP_RET_DATA: ::c_uint = 0x0000ffff;
22952332

2333+
pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: ::c_ulong = 1;
2334+
2335+
pub const SECCOMP_ADDFD_FLAG_SETFD: ::c_ulong = 1;
2336+
pub const SECCOMP_ADDFD_FLAG_SEND: ::c_ulong = 2;
2337+
22962338
pub const ITIMER_REAL: ::c_int = 0;
22972339
pub const ITIMER_VIRTUAL: ::c_int = 1;
22982340
pub const ITIMER_PROF: ::c_int = 2;

0 commit comments

Comments
 (0)