Skip to content
Open
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ util.pyc
57-basic-rawsysrc
58-live-tsync_notify
59-basic-empty_binary_tree
60-sim-32b_args_on_64b
86 changes: 86 additions & 0 deletions tests/60-sim-32b_args_on_64b.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Seccomp Library test program
*
* Copyright (c) 2022 Canonical Ltd.
* Author: James Henstridge <james.henstridge@canonical.com>
*/

/*
* This library is free software; you can redistribute it and/or modify it
* under the terms of version 2.1 of the GNU Lesser General Public License as
* published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, see <http://www.gnu.org/licenses>.
*/

#include <errno.h>
#include <unistd.h>
#include <inttypes.h>

#include <seccomp.h>

#include "util.h"

int main(int argc, char *argv[])
{
int rc;
struct util_options opts;
scmp_filter_ctx ctx = NULL;

rc = util_getopt(argc, argv, &opts);
if (rc < 0)
goto out;

ctx = seccomp_init(SCMP_ACT_KILL);
if (ctx == NULL)
return ENOMEM;

rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1001, 1,
SCMP_A0(SCMP_CMP_NE | SCMP_CMP_32BIT, 0x10));
if (rc != 0)
goto out;

rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1002, 1,
SCMP_A0(SCMP_CMP_LT | SCMP_CMP_32BIT, 0x10));
if (rc != 0)
goto out;

rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1003, 1,
SCMP_A0(SCMP_CMP_LE | SCMP_CMP_32BIT, 0x10));
if (rc != 0)
goto out;

rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1004, 1,
SCMP_A0(SCMP_CMP_EQ | SCMP_CMP_32BIT, 0x10));
if (rc != 0)
goto out;

rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1005, 1,
SCMP_A0(SCMP_CMP_GE | SCMP_CMP_32BIT, 0x10));
if (rc != 0)
goto out;

rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1006, 1,
SCMP_A0(SCMP_CMP_GT | SCMP_CMP_32BIT, 0x10));
if (rc != 0)
goto out;

rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, 1007, 1,
SCMP_A0(SCMP_CMP_MASKED_EQ | SCMP_CMP_32BIT, 0xff, 0x10));
if (rc != 0)
goto out;

rc = util_filter_output(&opts, ctx);
if (rc)
goto out;

out:
seccomp_release(ctx);
return (rc < 0 ? -rc : rc);
}
54 changes: 54 additions & 0 deletions tests/60-sim-32b_args_on_64b.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# libseccomp regression test automation data
#
# Copyright (c) 2022 Canonical Ltd.
# Author: James Henstridge <james.henstridge@canonical.com>
#

test type: bpf-sim

# Testname Arch Syscall Arg0 Arg1 Arg2 Arg3 Arg4 Arg5 Result
60-sim-32b_args_on_64b all 1001 0x1 N N N N N ALLOW
60-sim-32b_args_on_64b all 1001 0x10 N N N N N KILL
60-sim-32b_args_on_64b all 1001 0xffffffff00000001 N N N N N ALLOW
60-sim-32b_args_on_64b all 1001 0xffffffff00000010 N N N N N KILL

60-sim-32b_args_on_64b all 1002 0x1 N N N N N ALLOW
60-sim-32b_args_on_64b all 1002 0x20 N N N N N KILL
60-sim-32b_args_on_64b all 1002 0xffffffff00000001 N N N N N ALLOW
60-sim-32b_args_on_64b all 1002 0xffffffff00000020 N N N N N KILL

60-sim-32b_args_on_64b all 1003 0x10 N N N N N ALLOW
60-sim-32b_args_on_64b all 1003 0x20 N N N N N KILL
60-sim-32b_args_on_64b all 1003 0xffffffff00000010 N N N N N ALLOW
60-sim-32b_args_on_64b all 1003 0xffffffff00000020 N N N N N KILL

60-sim-32b_args_on_64b all 1004 0x10 N N N N N ALLOW
60-sim-32b_args_on_64b all 1004 0x20 N N N N N KILL
60-sim-32b_args_on_64b all 1004 0xffffffff00000010 N N N N N ALLOW
60-sim-32b_args_on_64b all 1004 0xffffffff00000020 N N N N N KILL

60-sim-32b_args_on_64b all 1005 0x10 N N N N N ALLOW
60-sim-32b_args_on_64b all 1005 0x01 N N N N N KILL
60-sim-32b_args_on_64b all 1005 0xffffffff00000010 N N N N N ALLOW
60-sim-32b_args_on_64b all 1005 0xffffffff00000001 N N N N N KILL

60-sim-32b_args_on_64b all 1006 0x20 N N N N N ALLOW
60-sim-32b_args_on_64b all 1006 0x01 N N N N N KILL
60-sim-32b_args_on_64b all 1006 0xffffffff00000020 N N N N N ALLOW
60-sim-32b_args_on_64b all 1006 0xffffffff00000001 N N N N N KILL

60-sim-32b_args_on_64b all 1007 0xff10 N N N N N ALLOW
60-sim-32b_args_on_64b all 1007 0x01 N N N N N KILL
60-sim-32b_args_on_64b all 1007 0xffffffff0000ff10 N N N N N ALLOW
60-sim-32b_args_on_64b all 1007 0xffffffff00000001 N N N N N KILL

test type: bpf-sim-fuzz

# Testname StressCount
60-sim-32b_args_on_64b 5

test type: bpf-valgrind

# Testname
60-sim-32b_args_on_64b
6 changes: 4 additions & 2 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ check_PROGRAMS = \
56-basic-iterate_syscalls \
57-basic-rawsysrc \
58-live-tsync_notify \
59-basic-empty_binary_tree
59-basic-empty_binary_tree \
60-sim-32b_args_on_64b
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the new tests :)


EXTRA_DIST_TESTPYTHON = \
util.py \
Expand Down Expand Up @@ -215,7 +216,8 @@ EXTRA_DIST_TESTCFGS = \
56-basic-iterate_syscalls.tests \
57-basic-rawsysrc.tests \
58-live-tsync_notify.tests \
59-basic-empty_binary_tree.tests
59-basic-empty_binary_tree.tests \
60-sim-32b_args_on_64b.tests

EXTRA_DIST_TESTSCRIPTS = \
38-basic-pfc_coverage.sh 38-basic-pfc_coverage.pfc \
Expand Down