Skip to content

Commit e0be7a3

Browse files
committed
RFE: Add SPARC support
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
1 parent e7e633c commit e0be7a3

24 files changed

Lines changed: 371 additions & 4 deletions

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ The libseccomp library currently supports the architectures listed below:
4848
* 64-bit PowerPC little endian (ppc64le)
4949
* 32-bit s390 (s390)
5050
* 64-bit s390x (s390x)
51+
* 32-bit SPARC (sparc)
52+
* 64-bit SPARC (sparc64)
5153
* 64-bit RISC-V (riscv64)
5254
* 32-bit SuperH big endian (sheb)
5355
* 32-bit SuperH (sh)

doc/man/man1/scmp_sys_resolver.1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ The architecture to use for resolving the system call. Valid
3636
.I ARCH
3737
values are "x86", "x86_64", "x32", "arm", "aarch64", "loongarch64", "m68k",
3838
"mips", "mipsel", "mips64", "mipsel64", "mips64n32", "mipsel64n32", "parisc",
39-
"parisc64", "ppc", "ppc64", "ppc64le", "s390", "s390x", "sheb" and "sh".
39+
"parisc64", "ppc", "ppc64", "ppc64le", "s390", "s390x", "sparc", "sparc64",
40+
"sheb" and "sh".
4041
.TP
4142
.B \-t
4243
If necessary, translate the system call name to the proper system call number,

include/seccomp-syscalls.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@
283283
#define __PNR_getpagesize -10249
284284
#define __PNR_riscv_hwprobe -10250
285285
#define __PNR_uretprobe -10251
286+
#define __PNR_execv -10252
287+
#define __PNR_getdomainname -10253
288+
#define __PNR_getresgid -10254
289+
#define __PNR_getresuid -10255
290+
#define __PNR_kern_features -10256
291+
#define __PNR_memory_ordering -10257
292+
#define __PNR_perfctr -10258
293+
#define __PNR_sched_get_affinity -10259
294+
#define __PNR_sched_set_affinity -10260
295+
#define __PNR_setresgid -10261
296+
#define __PNR_setresuid -10262
297+
#define __PNR_utrap_install -10263
286298

287299
/*
288300
* libseccomp syscall definitions
@@ -580,6 +592,8 @@
580592

581593
#define __SNR_eventfd2 __NR_eventfd2
582594

595+
#define __SNR_execv __NR_execv
596+
583597
#define __SNR_execve __NR_execve
584598

585599
#define __SNR_execveat __NR_execveat
@@ -648,6 +662,10 @@
648662

649663
#define __SNR_fgetxattr __NR_fgetxattr
650664

665+
#define __SNR_file_getattr __NR_file_getattr
666+
667+
#define __SNR_file_setattr __NR_file_setattr
668+
651669
#define __SNR_finit_module __NR_finit_module
652670

653671
#define __SNR_flistxattr __NR_flistxattr
@@ -802,6 +820,8 @@
802820

803821
#define __SNR_getdents64 __NR_getdents64
804822

823+
#define __SNR_getdomainname __NR_getdomainname
824+
805825
#ifdef __NR_getegid
806826
#define __SNR_getegid __NR_getegid
807827
#else
@@ -1036,6 +1056,8 @@
10361056

10371057
#define __SNR_kcmp __NR_kcmp
10381058

1059+
#define __SNR_kern_features __NR_kern_features
1060+
10391061
#ifdef __NR_kexec_file_load
10401062
#define __SNR_kexec_file_load __NR_kexec_file_load
10411063
#else
@@ -1152,6 +1174,8 @@
11521174
#define __SNR_memfd_secret __PNR_memfd_secret
11531175
#endif
11541176

1177+
#define __SNR_memory_ordering __NR_memory_ordering
1178+
11551179
#ifdef __NR_migrate_pages
11561180
#define __SNR_migrate_pages __NR_migrate_pages
11571181
#else
@@ -1356,6 +1380,8 @@
13561380
#define __SNR_open_tree __PNR_open_tree
13571381
#endif
13581382

1383+
#define __SNR_open_tree_attr __PNR_open_tree_attr
1384+
13591385
#define __SNR_openat __NR_openat
13601386

13611387
#define __SNR_openat2 __NR_openat2
@@ -1386,6 +1412,8 @@
13861412

13871413
#define __SNR_perf_event_open __NR_perf_event_open
13881414

1415+
#define __SNR_perfctr __PNR_perfctr
1416+
13891417
#define __SNR_personality __NR_personality
13901418

13911419
#define __SNR_pidfd_getfd __NR_pidfd_getfd
@@ -1672,6 +1700,8 @@
16721700
#define __SNR_s390_sthyi __PNR_s390_sthyi
16731701
#endif
16741702

1703+
#define __SNR_sched_get_affinity __NR_sched_get_affinity
1704+
16751705
#define __SNR_sched_get_priority_max __NR_sched_get_priority_max
16761706

16771707
#define __SNR_sched_get_priority_min __NR_sched_get_priority_min
@@ -1692,6 +1722,8 @@
16921722
#define __SNR_sched_rr_get_interval_time64 __PNR_sched_rr_get_interval_time64
16931723
#endif
16941724

1725+
#define __SNR_sched_set_affinity __NR_sched_set_affinity
1726+
16951727
#define __SNR_sched_setaffinity __NR_sched_setaffinity
16961728

16971729
#define __SNR_sched_setattr __NR_sched_setattr
@@ -2368,6 +2400,8 @@
23682400
#define __SNR_utimes __PNR_utimes
23692401
#endif
23702402

2403+
#define __SNR_utrap_install __PNR_utrap_install
2404+
23712405
#ifdef __NR_vfork
23722406
#define __SNR_vfork __NR_vfork
23732407
#else

include/seccomp.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ struct scmp_arg_cmp {
241241
#define SCMP_ARCH_SHEB AUDIT_ARCH_SH
242242
#define SCMP_ARCH_SH AUDIT_ARCH_SHEL /* Little-endian SH is more common than big */
243243

244+
/**
245+
* The SPARC architecture tokens
246+
*/
247+
#define SCMP_ARCH_SPARC AUDIT_ARCH_SPARC
248+
#define SCMP_ARCH_SPARC64 AUDIT_ARCH_SPARC64
249+
244250
/**
245251
* Convert a syscall name into the associated syscall number
246252
* @param x the syscall name

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ SOURCES_ALL = \
4545
arch-s390.h arch-s390.c \
4646
arch-s390x.h arch-s390x.c \
4747
arch-sh.h arch-sh.c \
48+
arch-sparc.h arch-sparc.c \
49+
arch-sparc64.h arch-sparc64.c \
4850
syscalls.h syscalls.c syscalls.perf.c
4951

5052
EXTRA_DIST = \

src/arch-sparc.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Enhanced Seccomp sparc Specific Code
3+
*
4+
* Copyright (c) 2015 Freescale <bogdan.purcareata@freescale.com>
5+
* 2025 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
6+
* Author: Bogdan Purcareata <bogdan.purcareata@freescale.com>
7+
* John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
8+
*
9+
* Derived from the PPC-specific code
10+
*
11+
*/
12+
13+
/*
14+
* This library is free software; you can redistribute it and/or modify it
15+
* under the terms of version 2.1 of the GNU Lesser General Public License as
16+
* published by the Free Software Foundation.
17+
*
18+
* This library is distributed in the hope that it will be useful, but WITHOUT
19+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
21+
* for more details.
22+
*
23+
* You should have received a copy of the GNU Lesser General Public License
24+
* along with this library; if not, see <http://www.gnu.org/licenses>.
25+
*/
26+
27+
#include <stdlib.h>
28+
#include <errno.h>
29+
#include <string.h>
30+
#include <linux/audit.h>
31+
32+
#include "db.h"
33+
#include "syscalls.h"
34+
#include "arch.h"
35+
#include "arch-sparc.h"
36+
37+
/* sparc syscall numbers */
38+
#define __sparc_NR_socketcall 206
39+
#define __sparc_NR_ipc 215
40+
41+
ARCH_DEF(sparc)
42+
43+
const struct arch_def arch_def_sparc = {
44+
.token = SCMP_ARCH_SPARC,
45+
.token_bpf = AUDIT_ARCH_SPARC,
46+
.size = ARCH_SIZE_32,
47+
.endian = ARCH_ENDIAN_BIG,
48+
.sys_socketcall = __sparc_NR_socketcall,
49+
.sys_ipc = __sparc_NR_ipc,
50+
.syscall_resolve_name = abi_syscall_resolve_name_munge,
51+
.syscall_resolve_name_raw = sparc_syscall_resolve_name,
52+
.syscall_resolve_num = abi_syscall_resolve_num_munge,
53+
.syscall_resolve_num_raw = sparc_syscall_resolve_num,
54+
.syscall_rewrite = abi_syscall_rewrite,
55+
.rule_add = abi_rule_add,
56+
.syscall_name_kver = sparc_syscall_name_kver,
57+
.syscall_num_kver = sparc_syscall_num_kver,
58+
};

src/arch-sparc.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Enhanced Seccomp sparc Specific Code
3+
*
4+
* Copyright (c) 2015 Freescale <bogdan.purcareata@freescale.com>
5+
* 2025 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
6+
* Author: Bogdan Purcareata <bogdan.purcareata@freescale.com>
7+
* John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
8+
*
9+
* Derived from the PPC-specific code
10+
*
11+
*/
12+
13+
/*
14+
* This library is free software; you can redistribute it and/or modify it
15+
* under the terms of version 2.1 of the GNU Lesser General Public License as
16+
* published by the Free Software Foundation.
17+
*
18+
* This library is distributed in the hope that it will be useful, but WITHOUT
19+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
21+
* for more details.
22+
*
23+
* You should have received a copy of the GNU Lesser General Public License
24+
* along with this library; if not, see <http://www.gnu.org/licenses>.
25+
*/
26+
27+
#ifndef _ARCH_SPARC_H
28+
#define _ARCH_SPARC_H
29+
30+
#include "arch.h"
31+
32+
#ifdef sparc
33+
#undef sparc
34+
#endif
35+
36+
ARCH_DECL(sparc)
37+
38+
#endif

src/arch-sparc64.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Enhanced Seccomp sparc64 Specific Code
3+
*
4+
* Copyright (c) 2015 Freescale <bogdan.purcareata@freescale.com>
5+
* 2025 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
6+
* Author: Bogdan Purcareata <bogdan.purcareata@freescale.com>
7+
* John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
8+
*
9+
* Derived from the PPC-specific code
10+
*
11+
*/
12+
13+
/*
14+
* This library is free software; you can redistribute it and/or modify it
15+
* under the terms of version 2.1 of the GNU Lesser General Public License as
16+
* published by the Free Software Foundation.
17+
*
18+
* This library is distributed in the hope that it will be useful, but WITHOUT
19+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
21+
* for more details.
22+
*
23+
* You should have received a copy of the GNU Lesser General Public License
24+
* along with this library; if not, see <http://www.gnu.org/licenses>.
25+
*/
26+
27+
#include <stdlib.h>
28+
#include <errno.h>
29+
#include <string.h>
30+
#include <linux/audit.h>
31+
32+
#include "db.h"
33+
#include "syscalls.h"
34+
#include "arch.h"
35+
#include "arch-sparc64.h"
36+
37+
/* sparc64 syscall numbers */
38+
#define __sparc64_NR_socketcall 206
39+
#define __sparc64_NR_ipc 215
40+
41+
ARCH_DEF(sparc64)
42+
43+
const struct arch_def arch_def_sparc64 = {
44+
.token = SCMP_ARCH_SPARC64,
45+
.token_bpf = AUDIT_ARCH_SPARC64,
46+
.size = ARCH_SIZE_64,
47+
.endian = ARCH_ENDIAN_BIG,
48+
.sys_socketcall = __sparc64_NR_socketcall,
49+
.sys_ipc = __sparc64_NR_ipc,
50+
.syscall_resolve_name = abi_syscall_resolve_name_munge,
51+
.syscall_resolve_name_raw = sparc64_syscall_resolve_name,
52+
.syscall_resolve_num = abi_syscall_resolve_num_munge,
53+
.syscall_resolve_num_raw = sparc64_syscall_resolve_num,
54+
.syscall_rewrite = abi_syscall_rewrite,
55+
.rule_add = abi_rule_add,
56+
.syscall_name_kver = sparc64_syscall_name_kver,
57+
.syscall_num_kver = sparc64_syscall_num_kver,
58+
};

src/arch-sparc64.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Enhanced Seccomp sparc64 Specific Code
3+
*
4+
* Copyright (c) 2015 Freescale <bogdan.purcareata@freescale.com>
5+
* 2025 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
6+
* Author: Bogdan Purcareata <bogdan.purcareata@freescale.com>
7+
* John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
8+
*
9+
* Derived from the PPC-specific code
10+
*
11+
*/
12+
13+
/*
14+
* This library is free software; you can redistribute it and/or modify it
15+
* under the terms of version 2.1 of the GNU Lesser General Public License as
16+
* published by the Free Software Foundation.
17+
*
18+
* This library is distributed in the hope that it will be useful, but WITHOUT
19+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
21+
* for more details.
22+
*
23+
* You should have received a copy of the GNU Lesser General Public License
24+
* along with this library; if not, see <http://www.gnu.org/licenses>.
25+
*/
26+
27+
#ifndef _ARCH_SPARC64_H
28+
#define _ARCH_SPARC64_H
29+
30+
#include "arch.h"
31+
32+
ARCH_DECL(sparc64)
33+
34+
#endif

src/arch-syscall-dump.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include "arch-s390.h"
4949
#include "arch-s390x.h"
5050
#include "arch-sh.h"
51+
#include "arch-sparc.h"
52+
#include "arch-sparc64.h"
5153

5254
/**
5355
* Print the usage information to stderr and exit
@@ -153,6 +155,12 @@ int main(int argc, char *argv[])
153155
case SCMP_ARCH_SHEB:
154156
sys = sh_syscall_iterate(iter);
155157
break;
158+
case SCMP_ARCH_SPARC:
159+
sys = sparc_syscall_iterate(iter);
160+
break;
161+
case SCMP_ARCH_SPARC64:
162+
sys = sparc64_syscall_iterate(iter);
163+
break;
156164
default:
157165
/* invalid arch */
158166
exit_usage(argv[0]);

0 commit comments

Comments
 (0)