Skip to content

Commit c4767aa

Browse files
committed
Auto merge of #2233 - devnexen:linux_seccomp, r=JohnTitor
linux/android adding seccomp filter and data types.
2 parents 5743a27 + a41a07f commit c4767aa

File tree

7 files changed

+123
-0
lines changed

7 files changed

+123
-0
lines changed

libc-test/semver/android.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,9 +1777,25 @@ SCM_CREDENTIALS
17771777
SCM_RIGHTS
17781778
SCM_TIMESTAMP
17791779

1780+
SECCOMP_FILTER_FLAG_LOG
1781+
SECCOMP_FILTER_FLAG_NEW_LISTENER
1782+
SECCOMP_FILTER_FLAG_SPEC_ALLOW
1783+
SECCOMP_FILTER_FLAG_TSYNC
17801784
SECCOMP_MODE_DISABLED
17811785
SECCOMP_MODE_FILTER
17821786
SECCOMP_MODE_STRICT
1787+
SECCOMP_RET_ACTION
1788+
SECCOMP_RET_ACTION_FULL
1789+
SECCOMP_RET_ALLOW
1790+
SECCOMP_RET_DATA
1791+
SECCOMP_RET_ERRNO
1792+
SECCOMP_RET_KILL
1793+
SECCOMP_RET_KILL_PROCESS
1794+
SECCOMP_RET_KILL_THREAD
1795+
SECCOMP_RET_LOG
1796+
SECCOMP_RET_TRACE
1797+
SECCOMP_RET_TRAP
1798+
SECCOMP_RET_USER_NOTIF
17831799
SEEK_CUR
17841800
SEEK_DATA
17851801
SEEK_END
@@ -3048,6 +3064,7 @@ sched_setaffinity
30483064
sched_setparam
30493065
sched_setscheduler
30503066
sched_yield
3067+
seccomp_data
30513068
seekdir
30523069
select
30533070
sem_close
@@ -3121,6 +3138,8 @@ size_t
31213138
sleep
31223139
snprintf
31233140
sock_extended_err
3141+
sock_filter
3142+
sock_fprog
31243143
sockaddr
31253144
sockaddr_alg
31263145
sockaddr_in

libc-test/semver/linux.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,9 +1934,23 @@ SCM_CREDENTIALS
19341934
SCM_RIGHTS
19351935
SCM_TIMESTAMP
19361936
SCM_TIMESTAMPING
1937+
SECCOMP_FILTER_FLAG_LOG
1938+
SECCOMP_FILTER_FLAG_SPEC_ALLOW
1939+
SECCOMP_FILTER_FLAG_TSYNC
19371940
SECCOMP_MODE_DISABLED
19381941
SECCOMP_MODE_FILTER
19391942
SECCOMP_MODE_STRICT
1943+
SECCOMP_RET_ACTION
1944+
SECCOMP_RET_ACTION_FULL
1945+
SECCOMP_RET_ALLOW
1946+
SECCOMP_RET_DATA
1947+
SECCOMP_RET_ERRNO
1948+
SECCOMP_RET_KILL
1949+
SECCOMP_RET_KILL_PROCESS
1950+
SECCOMP_RET_KILL_THREAD
1951+
SECCOMP_RET_LOG
1952+
SECCOMP_RET_TRACE
1953+
SECCOMP_RET_TRAP
19401954
SEEK_DATA
19411955
SEEK_HOLE
19421956
SEM_FAILED
@@ -2939,6 +2953,7 @@ sched_rr_get_interval
29392953
sched_setaffinity
29402954
sched_setparam
29412955
sched_setscheduler
2956+
seccomp_data
29422957
seekdir
29432958
sem_close
29442959
sem_destroy
@@ -2990,6 +3005,8 @@ sigtimedwait
29903005
sigwait
29913006
sigwaitinfo
29923007
sock_extended_err
3008+
sock_filter
3009+
sock_fprog
29933010
sockaddr_alg
29943011
sockaddr_can
29953012
sockaddr_ll

src/unix/linux_like/android/b32/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub type off64_t = ::c_longlong;
88
pub type sigset_t = ::c_ulong;
99
pub type socklen_t = i32;
1010
pub type time64_t = i64;
11+
pub type __u64 = ::c_ulonglong;
1112

1213
s! {
1314
pub struct sigaction {

src/unix/linux_like/android/b64/aarch64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub type c_char = u8;
22
pub type wchar_t = u32;
3+
pub type __u64 = ::c_ulonglong;
34

45
s! {
56
pub struct stat {

src/unix/linux_like/android/b64/x86_64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub type c_char = i8;
22
pub type wchar_t = i32;
33
pub type greg_t = i64;
4+
pub type __u64 = ::c_ulonglong;
45

56
s! {
67
pub struct stat {

src/unix/linux_like/android/mod.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ pub type loff_t = ::c_longlong;
2626
pub type __kernel_loff_t = ::c_longlong;
2727
pub type __kernel_pid_t = ::c_int;
2828

29+
pub type __u8 = ::c_uchar;
30+
pub type __u16 = ::c_ushort;
31+
pub type __s16 = ::c_short;
32+
pub type __u32 = ::c_uint;
33+
pub type __s32 = ::c_int;
34+
2935
// linux/elf.h
3036

3137
pub type Elf32_Addr = u32;
@@ -321,6 +327,27 @@ s! {
321327
pub dlpi_tls_modid: ::size_t,
322328
pub dlpi_tls_data: *mut ::c_void,
323329
}
330+
331+
// linux/filter.h
332+
pub struct sock_filter {
333+
pub code: ::__u16,
334+
pub jt: ::__u8,
335+
pub jf: ::__u8,
336+
pub k: ::__u32,
337+
}
338+
339+
pub struct sock_fprog {
340+
pub len: ::c_ushort,
341+
pub filter: *mut sock_filter,
342+
}
343+
344+
// linux/seccomp.h
345+
pub struct seccomp_data {
346+
pub nr: ::c_int,
347+
pub arch: ::__u32,
348+
pub instruction_pointer: ::__u64,
349+
pub args: [::__u64; 6],
350+
}
324351
}
325352

326353
s_no_extra_traits! {
@@ -1741,6 +1768,25 @@ pub const SECCOMP_MODE_DISABLED: ::c_uint = 0;
17411768
pub const SECCOMP_MODE_STRICT: ::c_uint = 1;
17421769
pub const SECCOMP_MODE_FILTER: ::c_uint = 2;
17431770

1771+
pub const SECCOMP_FILTER_FLAG_TSYNC: ::c_ulong = 1;
1772+
pub const SECCOMP_FILTER_FLAG_LOG: ::c_ulong = 2;
1773+
pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: ::c_ulong = 4;
1774+
pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: ::c_ulong = 8;
1775+
1776+
pub const SECCOMP_RET_ACTION_FULL: ::c_uint = 0xffff0000;
1777+
pub const SECCOMP_RET_ACTION: ::c_uint = 0x7fff0000;
1778+
pub const SECCOMP_RET_DATA: ::c_uint = 0x0000ffff;
1779+
1780+
pub const SECCOMP_RET_KILL_PROCESS: ::c_uint = 0x80000000;
1781+
pub const SECCOMP_RET_KILL_THREAD: ::c_uint = 0x00000000;
1782+
pub const SECCOMP_RET_KILL: ::c_uint = SECCOMP_RET_KILL_THREAD;
1783+
pub const SECCOMP_RET_TRAP: ::c_uint = 0x00030000;
1784+
pub const SECCOMP_RET_ERRNO: ::c_uint = 0x00050000;
1785+
pub const SECCOMP_RET_USER_NOTIF: ::c_uint = 0x7fc00000;
1786+
pub const SECCOMP_RET_TRACE: ::c_uint = 0x7ff00000;
1787+
pub const SECCOMP_RET_LOG: ::c_uint = 0x7ffc0000;
1788+
pub const SECCOMP_RET_ALLOW: ::c_uint = 0x7fff0000;
1789+
17441790
pub const NLA_F_NESTED: ::c_int = 1 << 15;
17451791
pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14;
17461792
pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);

src/unix/linux_like/linux/mod.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,27 @@ s! {
541541
pub can_id: canid_t,
542542
pub can_mask: canid_t,
543543
}
544+
545+
// linux/filter.h
546+
pub struct sock_filter {
547+
pub code: ::__u16,
548+
pub jt: ::__u8,
549+
pub jf: ::__u8,
550+
pub k: ::__u32,
551+
}
552+
553+
pub struct sock_fprog {
554+
pub len: ::c_ushort,
555+
pub filter: *mut sock_filter,
556+
}
557+
558+
// linux/seccomp.h
559+
pub struct seccomp_data {
560+
pub nr: ::c_int,
561+
pub arch: ::__u32,
562+
pub instruction_pointer: ::__u64,
563+
pub args: [::__u64; 6],
564+
}
544565
}
545566

546567
s_no_extra_traits! {
@@ -1704,6 +1725,23 @@ pub const SECCOMP_MODE_DISABLED: ::c_uint = 0;
17041725
pub const SECCOMP_MODE_STRICT: ::c_uint = 1;
17051726
pub const SECCOMP_MODE_FILTER: ::c_uint = 2;
17061727

1728+
pub const SECCOMP_FILTER_FLAG_TSYNC: ::c_ulong = 1;
1729+
pub const SECCOMP_FILTER_FLAG_LOG: ::c_ulong = 2;
1730+
pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: ::c_ulong = 4;
1731+
1732+
pub const SECCOMP_RET_KILL_PROCESS: ::c_uint = 0x80000000;
1733+
pub const SECCOMP_RET_KILL_THREAD: ::c_uint = 0x00000000;
1734+
pub const SECCOMP_RET_KILL: ::c_uint = SECCOMP_RET_KILL_THREAD;
1735+
pub const SECCOMP_RET_TRAP: ::c_uint = 0x00030000;
1736+
pub const SECCOMP_RET_ERRNO: ::c_uint = 0x00050000;
1737+
pub const SECCOMP_RET_TRACE: ::c_uint = 0x7ff00000;
1738+
pub const SECCOMP_RET_LOG: ::c_uint = 0x7ffc0000;
1739+
pub const SECCOMP_RET_ALLOW: ::c_uint = 0x7fff0000;
1740+
1741+
pub const SECCOMP_RET_ACTION_FULL: ::c_uint = 0xffff0000;
1742+
pub const SECCOMP_RET_ACTION: ::c_uint = 0x7fff0000;
1743+
pub const SECCOMP_RET_DATA: ::c_uint = 0x0000ffff;
1744+
17071745
pub const ITIMER_REAL: ::c_int = 0;
17081746
pub const ITIMER_VIRTUAL: ::c_int = 1;
17091747
pub const ITIMER_PROF: ::c_int = 2;

0 commit comments

Comments
 (0)