diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-05-17 08:17:06 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-05-17 11:00:06 +0200 |
commit | 504d9e38a528ca8bf6f658223a1935e9bc537d8a (patch) | |
tree | 722ccef57b467de309a30a2e7742da033b69db42 /operations.c | |
parent | 16346c99a674d95970cfc59b0aa5d00e91cc4e0f (diff) | |
download | seitan-504d9e38a528ca8bf6f658223a1935e9bc537d8a.tar seitan-504d9e38a528ca8bf6f658223a1935e9bc537d8a.tar.gz seitan-504d9e38a528ca8bf6f658223a1935e9bc537d8a.tar.bz2 seitan-504d9e38a528ca8bf6f658223a1935e9bc537d8a.tar.lz seitan-504d9e38a528ca8bf6f658223a1935e9bc537d8a.tar.xz seitan-504d9e38a528ca8bf6f658223a1935e9bc537d8a.tar.zst seitan-504d9e38a528ca8bf6f658223a1935e9bc537d8a.zip |
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
Diffstat (limited to 'operations.c')
-rw-r--r-- | operations.c | 29 |
1 files changed, 29 insertions, 0 deletions
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); } |