|
Packit Service |
10c312 |
/**
|
|
Packit Service |
10c312 |
* Seccomp Library test program
|
|
Packit Service |
10c312 |
*
|
|
Packit Service |
10c312 |
* Copyright (c) 2020 Red Hat <gscrivan@redhat.com>
|
|
Packit Service |
10c312 |
* Author: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
Packit Service |
10c312 |
*/
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
/*
|
|
Packit Service |
10c312 |
* This library is free software; you can redistribute it and/or modify it
|
|
Packit Service |
10c312 |
* under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
Packit Service |
10c312 |
* published by the Free Software Foundation.
|
|
Packit Service |
10c312 |
*
|
|
Packit Service |
10c312 |
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
10c312 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit Service |
10c312 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
Packit Service |
10c312 |
* for more details.
|
|
Packit Service |
10c312 |
*
|
|
Packit Service |
10c312 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
10c312 |
* along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
Packit Service |
10c312 |
*/
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
#include <errno.h>
|
|
Packit Service |
10c312 |
#include <string.h>
|
|
Packit Service |
10c312 |
#include <stdlib.h>
|
|
Packit Service |
10c312 |
#include <stdio.h>
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
#include <seccomp.h>
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
unsigned int arch_list[] = {
|
|
Packit Service |
10c312 |
SCMP_ARCH_NATIVE,
|
|
Packit Service |
10c312 |
SCMP_ARCH_X86,
|
|
Packit Service |
10c312 |
SCMP_ARCH_X86_64,
|
|
Packit Service |
10c312 |
SCMP_ARCH_X32,
|
|
Packit Service |
10c312 |
SCMP_ARCH_ARM,
|
|
Packit Service |
10c312 |
SCMP_ARCH_AARCH64,
|
|
Packit Service |
10c312 |
SCMP_ARCH_MIPS,
|
|
Packit Service |
10c312 |
SCMP_ARCH_MIPS64,
|
|
Packit Service |
10c312 |
SCMP_ARCH_MIPS64N32,
|
|
Packit Service |
10c312 |
SCMP_ARCH_MIPSEL,
|
|
Packit Service |
10c312 |
SCMP_ARCH_MIPSEL64,
|
|
Packit Service |
10c312 |
SCMP_ARCH_MIPSEL64N32,
|
|
Packit Service |
10c312 |
SCMP_ARCH_PPC,
|
|
Packit Service |
10c312 |
SCMP_ARCH_PPC64,
|
|
Packit Service |
10c312 |
SCMP_ARCH_PPC64LE,
|
|
Packit Service |
10c312 |
SCMP_ARCH_S390,
|
|
Packit Service |
10c312 |
SCMP_ARCH_S390X,
|
|
Packit Service |
10c312 |
SCMP_ARCH_PARISC,
|
|
Packit Service |
10c312 |
SCMP_ARCH_PARISC64,
|
|
Packit Service |
10c312 |
SCMP_ARCH_RISCV64,
|
|
Packit Service |
10c312 |
-1
|
|
Packit Service |
10c312 |
};
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
static int test_arch(int arch, int init)
|
|
Packit Service |
10c312 |
{
|
|
Packit Service |
10c312 |
int n, iter = 0;
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
for (iter = init; iter < init + 1000; iter++) {
|
|
Packit Service |
10c312 |
char *name;
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
name = seccomp_syscall_resolve_num_arch(arch, iter);
|
|
Packit Service |
10c312 |
if (name == NULL)
|
|
Packit Service |
10c312 |
continue;
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
n = seccomp_syscall_resolve_name_arch(arch, name);
|
|
Packit Service |
10c312 |
if (n != iter)
|
|
Packit Service |
10c312 |
return 1;
|
|
Packit Service |
10c312 |
}
|
|
Packit Service |
10c312 |
return 0;
|
|
Packit Service |
10c312 |
}
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
int main(int argc, char *argv[])
|
|
Packit Service |
10c312 |
{
|
|
Packit Service |
10c312 |
int iter = 0;
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
for (iter = 0; arch_list[iter] != -1; iter++) {
|
|
Packit Service |
10c312 |
int init = 0;
|
|
Packit Service |
10c312 |
if (arch_list[iter] == SCMP_ARCH_X32)
|
|
Packit Service |
10c312 |
init = 0x40000000;
|
|
Packit Service |
10c312 |
else if (arch_list[iter] == SCMP_ARCH_MIPS)
|
|
Packit Service |
10c312 |
init = 4000;
|
|
Packit Service |
10c312 |
else if (arch_list[iter] == SCMP_ARCH_MIPS64)
|
|
Packit Service |
10c312 |
init = 5000;
|
|
Packit Service |
10c312 |
else if (arch_list[iter] == SCMP_ARCH_MIPS64N32)
|
|
Packit Service |
10c312 |
init = 6000;
|
|
Packit Service |
10c312 |
if (test_arch(arch_list[iter], init) < 0)
|
|
Packit Service |
10c312 |
return 1;
|
|
Packit Service |
10c312 |
}
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
return 0;
|
|
Packit Service |
10c312 |
}
|