summaryrefslogtreecommitdiff
path: root/src/arch.c
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2021-08-04 11:51:12 -0400
committerPaul Moore <paul@paul-moore.com>2021-08-12 12:30:34 -0400
commit17cbd2c253ce63e5e9e3cec867ff58efbe8b5fdc (patch)
treedb15f9ddc82f016889ba2c8bf2fafa8002d751a3 /src/arch.c
parentc261232174c8432e12c39e2fc938a64d562de1d6 (diff)
downloadlibseccomp-17cbd2c253ce63e5e9e3cec867ff58efbe8b5fdc.tar.gz
arch: consolidate all of the multiplexed syscall handling
Not only does this reduce the amount of duplicated code significantly, it removes a lot of the "magic" numbers in the code, and it happened to catch some bugs too. Acked-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'src/arch.c')
-rw-r--r--src/arch.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/arch.c b/src/arch.c
index 6ab922f..921e455 100644
--- a/src/arch.c
+++ b/src/arch.c
@@ -315,7 +315,9 @@ int arch_arg_offset(const struct arch_def *arch, unsigned int arg)
int arch_syscall_resolve_name(const struct arch_def *arch, const char *name)
{
if (arch->syscall_resolve_name)
- return (*arch->syscall_resolve_name)(name);
+ return (*arch->syscall_resolve_name)(arch, name);
+ if (arch->syscall_resolve_name_raw)
+ return (*arch->syscall_resolve_name_raw)(name);
return __NR_SCMP_ERROR;
}
@@ -333,7 +335,9 @@ int arch_syscall_resolve_name(const struct arch_def *arch, const char *name)
const char *arch_syscall_resolve_num(const struct arch_def *arch, int num)
{
if (arch->syscall_resolve_num)
- return (*arch->syscall_resolve_num)(num);
+ return (*arch->syscall_resolve_num)(arch, num);
+ if (arch->syscall_resolve_num_raw)
+ return (*arch->syscall_resolve_num_raw)(num);
return NULL;
}
@@ -396,7 +400,7 @@ int arch_syscall_rewrite(const struct arch_def *arch, int *syscall)
} else if (sys > -10000) {
/* rewritable syscalls */
if (arch->syscall_rewrite)
- (*arch->syscall_rewrite)(syscall);
+ (*arch->syscall_rewrite)(arch, syscall);
}
/* syscalls not defined on this architecture */