A number of arches/ABIs have either syscall offsets (the MIPS
family) or specific bits (x32) which are applied to their normal
syscall numbers. We generally handle that via "munging" in
libseccomp, and it works reasonably well. Unfortunately we were
applying this munging process to the negative pseudo syscall
numbers as well and this was causing problems.
This patch fixes the various offset/bit arches/ABIs by not applying
the munging to the negative pseudo syscall numbers.
This resolves GH issue #284:
* https://github.com/seccomp/libseccomp/issues/284
Reported-by: Harald van Dijk <harald@gigawatt.nl>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
(imported from commit
34cde704979defcbddb8eea64295acf0e477c250)
Gbp-Pq: Name arch_ensure_we_dont_munge_pseudo_syscall_numbers.patch
{
int sys;
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
sys = arm_syscall_resolve_name(name);
- if (sys == __NR_SCMP_ERROR)
+ if (sys == __NR_SCMP_ERROR || sys < 0)
return sys;
return (sys | __SCMP_NR_BASE);
*/
const char *arm_syscall_resolve_num_munge(int num)
{
- return arm_syscall_resolve_num(num & (~__SCMP_NR_BASE));
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
+ if (num >= 0)
+ num &= ~__SCMP_NR_BASE;
+ return arm_syscall_resolve_num(num);
}
const struct arch_def arch_def_arm = {
{
int sys;
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
sys = mips_syscall_resolve_name(name);
- if (sys == __NR_SCMP_ERROR)
+ if (sys == __NR_SCMP_ERROR || sys < 0)
return sys;
return sys + __SCMP_NR_BASE;
*/
const char *mips_syscall_resolve_num_munge(int num)
{
- return mips_syscall_resolve_num(num - __SCMP_NR_BASE);
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
+ if (num >= __SCMP_NR_BASE)
+ num -= __SCMP_NR_BASE;
+ return mips_syscall_resolve_num(num);
}
const struct arch_def arch_def_mips = {
{
int sys;
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
sys = mips64_syscall_resolve_name(name);
- if (sys == __NR_SCMP_ERROR)
+ if (sys == __NR_SCMP_ERROR || sys < 0)
return sys;
return sys + __SCMP_NR_BASE;
*/
const char *mips64_syscall_resolve_num_munge(int num)
{
- return mips64_syscall_resolve_num(num - __SCMP_NR_BASE);
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
+ if (num >= __SCMP_NR_BASE)
+ num -= __SCMP_NR_BASE;
+ return mips64_syscall_resolve_num(num);
}
const struct arch_def arch_def_mips64 = {
{
int sys;
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
sys = mips64n32_syscall_resolve_name(name);
- if (sys == __NR_SCMP_ERROR)
+ if (sys == __NR_SCMP_ERROR || sys < 0)
return sys;
return sys + __SCMP_NR_BASE;
*/
const char *mips64n32_syscall_resolve_num_munge(int num)
{
- return mips64n32_syscall_resolve_num(num - __SCMP_NR_BASE);
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
+ if (num >= __SCMP_NR_BASE)
+ num -= __SCMP_NR_BASE;
+ return mips64n32_syscall_resolve_num(num);
}
const struct arch_def arch_def_mips64n32 = {
{
int sys;
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
sys = x32_syscall_resolve_name(name);
- if (sys == __NR_SCMP_ERROR)
+ if (sys == __NR_SCMP_ERROR || sys < 0)
return sys;
return (sys | X32_SYSCALL_BIT);
*/
const char *x32_syscall_resolve_num_munge(int num)
{
- return x32_syscall_resolve_num(num & (~X32_SYSCALL_BIT));
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
+ if (num >= 0)
+ num &= ~X32_SYSCALL_BIT;
+ return x32_syscall_resolve_num(num);
}
const struct arch_def arch_def_x32 = {