|
Packit |
56e23f |
/**
|
|
Packit |
56e23f |
* Enhanced Seccomp MIPS64 Specific Code
|
|
Packit |
56e23f |
*
|
|
Packit |
56e23f |
* Copyright (c) 2014 Red Hat <pmoore@redhat.com>
|
|
Packit |
56e23f |
* Author: Paul Moore <paul@paul-moore.com>
|
|
Packit |
56e23f |
*
|
|
Packit |
56e23f |
*/
|
|
Packit |
56e23f |
|
|
Packit |
56e23f |
/*
|
|
Packit |
56e23f |
* This library is free software; you can redistribute it and/or modify it
|
|
Packit |
56e23f |
* under the terms of version 2.1 of the GNU Lesser General Public License as
|
|
Packit |
56e23f |
* published by the Free Software Foundation.
|
|
Packit |
56e23f |
*
|
|
Packit |
56e23f |
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit |
56e23f |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit |
56e23f |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
Packit |
56e23f |
* for more details.
|
|
Packit |
56e23f |
*
|
|
Packit |
56e23f |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
56e23f |
* along with this library; if not, see <http://www.gnu.org/licenses>.
|
|
Packit |
56e23f |
*/
|
|
Packit |
56e23f |
|
|
Packit |
56e23f |
#include <linux/audit.h>
|
|
Packit |
56e23f |
|
|
Packit |
56e23f |
#include "arch.h"
|
|
Packit |
56e23f |
#include "arch-mips64.h"
|
|
Packit |
56e23f |
|
|
Packit Service |
10c312 |
/* 64 ABI */
|
|
Packit Service |
10c312 |
#define __SCMP_NR_BASE 5000
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
/**
|
|
Packit Service |
10c312 |
* Resolve a syscall name to a number
|
|
Packit Service |
10c312 |
* @param name the syscall name
|
|
Packit Service |
10c312 |
*
|
|
Packit Service |
10c312 |
* Resolve the given syscall name to the syscall number using the syscall table.
|
|
Packit Service |
10c312 |
* Returns the syscall number on success, including negative pseudo syscall
|
|
Packit Service |
10c312 |
* numbers; returns __NR_SCMP_ERROR on failure.
|
|
Packit Service |
10c312 |
*
|
|
Packit Service |
10c312 |
*/
|
|
Packit Service |
10c312 |
int mips64_syscall_resolve_name_munge(const char *name)
|
|
Packit Service |
10c312 |
{
|
|
Packit Service |
10c312 |
int sys;
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
/* NOTE: we don't want to modify the pseudo-syscall numbers */
|
|
Packit Service |
10c312 |
sys = mips64_syscall_resolve_name(name);
|
|
Packit Service |
10c312 |
if (sys == __NR_SCMP_ERROR || sys < 0)
|
|
Packit Service |
10c312 |
return sys;
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
return sys + __SCMP_NR_BASE;
|
|
Packit Service |
10c312 |
}
|
|
Packit Service |
10c312 |
|
|
Packit Service |
10c312 |
/**
|
|
Packit Service |
10c312 |
* Resolve a syscall number to a name
|
|
Packit Service |
10c312 |
* @param num the syscall number
|
|
Packit Service |
10c312 |
*
|
|
Packit Service |
10c312 |
* Resolve the given syscall number to the syscall name using the syscall table.
|
|
Packit Service |
10c312 |
* Returns a pointer to the syscall name string on success, including pseudo
|
|
Packit Service |
10c312 |
* syscall names; returns NULL on failure.
|
|
Packit Service |
10c312 |
*
|
|
Packit Service |
10c312 |
*/
|
|
Packit Service |
10c312 |
const char *mips64_syscall_resolve_num_munge(int num)
|
|
Packit Service |
10c312 |
{
|
|
Packit Service |
10c312 |
/* NOTE: we don't want to modify the pseudo-syscall numbers */
|
|
Packit Service |
10c312 |
if (num >= __SCMP_NR_BASE)
|
|
Packit Service |
10c312 |
num -= __SCMP_NR_BASE;
|
|
Packit Service |
10c312 |
return mips64_syscall_resolve_num(num);
|
|
Packit Service |
10c312 |
}
|
|
Packit Service |
10c312 |
|
|
Packit |
56e23f |
const struct arch_def arch_def_mips64 = {
|
|
Packit |
56e23f |
.token = SCMP_ARCH_MIPS64,
|
|
Packit |
56e23f |
.token_bpf = AUDIT_ARCH_MIPS64,
|
|
Packit |
56e23f |
.size = ARCH_SIZE_64,
|
|
Packit |
56e23f |
.endian = ARCH_ENDIAN_BIG,
|
|
Packit Service |
10c312 |
.syscall_resolve_name = mips64_syscall_resolve_name_munge,
|
|
Packit Service |
10c312 |
.syscall_resolve_num = mips64_syscall_resolve_num_munge,
|
|
Packit |
56e23f |
.syscall_rewrite = NULL,
|
|
Packit |
56e23f |
.rule_add = NULL,
|
|
Packit |
56e23f |
};
|
|
Packit |
56e23f |
|
|
Packit |
56e23f |
const struct arch_def arch_def_mipsel64 = {
|
|
Packit |
56e23f |
.token = SCMP_ARCH_MIPSEL64,
|
|
Packit |
56e23f |
.token_bpf = AUDIT_ARCH_MIPSEL64,
|
|
Packit |
56e23f |
.size = ARCH_SIZE_64,
|
|
Packit |
56e23f |
.endian = ARCH_ENDIAN_LITTLE,
|
|
Packit Service |
10c312 |
.syscall_resolve_name = mips64_syscall_resolve_name_munge,
|
|
Packit Service |
10c312 |
.syscall_resolve_num = mips64_syscall_resolve_num_munge,
|
|
Packit |
56e23f |
.syscall_rewrite = NULL,
|
|
Packit |
56e23f |
.rule_add = NULL,
|
|
Packit |
56e23f |
};
|