From 504d9e38a528ca8bf6f658223a1935e9bc537d8a Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Wed, 17 May 2023 08:17:06 +0200 Subject: ops: add op_nr and op_copy Add: - missing implementation for op_nr - op_copy to copy data - tests for op_nr and op_data --- operations.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'operations.c') diff --git a/operations.c b/operations.c index f4adb0a..f79c41c 100644 --- a/operations.c +++ b/operations.c @@ -385,6 +385,33 @@ int op_resolve_fd(const struct seccomp_notif *req, int notifier, return 0; } +int op_nr(const struct seccomp_notif *req, int notifier, struct gluten *g, + struct op_nr *op) +{ + long nr; + int jmp; + + (void)notifier; + + if (gluten_read(NULL, g, &nr, op->nr, sizeof(nr)) == -1) + return -1; + if (gluten_read(NULL, g, &jmp, op->no_match, sizeof(jmp)) == -1) + return -1; + if (nr == req->data.nr) + return jmp; + + return 0; +} + +int op_copy(const struct seccomp_notif *req, int notifier, struct gluten *g, + struct op_copy *op) +{ + (void)notifier; + + return gluten_write(g, op->dst, gluten_ptr(&req->data, g, op->src), + op->size); +} + int eval(struct gluten *g, const struct seccomp_notif *req, int notifier) { @@ -401,6 +428,8 @@ int eval(struct gluten *g, const struct seccomp_notif *req, HANDLE_OP(OP_LOAD, op_load, load); HANDLE_OP(OP_CMP, op_cmp, cmp); HANDLE_OP(OP_RESOLVEDFD, op_resolve_fd, resfd); + HANDLE_OP(OP_NR, op_nr, nr); + HANDLE_OP(OP_COPY, op_copy, copy); default: ret_err(-1, "unknown operation %d", op->type); } -- cgit v1.2.3