aboutgitcodelistschat:MatrixIRC
path: root/cooker/emit.h
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-08-13 18:50:33 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-08-13 19:00:35 +0200
commit9bf3b1cc7a94357c250f77f16829c96cbae801fe (patch)
tree56cbc184974b18d33aa288dda7b12e5a77c38a94 /cooker/emit.h
parentd699dac08778c597eefac1067a325059925e87e6 (diff)
downloadseitan-9bf3b1cc7a94357c250f77f16829c96cbae801fe.tar
seitan-9bf3b1cc7a94357c250f77f16829c96cbae801fe.tar.gz
seitan-9bf3b1cc7a94357c250f77f16829c96cbae801fe.tar.bz2
seitan-9bf3b1cc7a94357c250f77f16829c96cbae801fe.tar.lz
seitan-9bf3b1cc7a94357c250f77f16829c96cbae801fe.tar.xz
seitan-9bf3b1cc7a94357c250f77f16829c96cbae801fe.tar.zst
seitan-9bf3b1cc7a94357c250f77f16829c96cbae801fe.zip
call, emit, match: Add support for vectorised operations, nfnetlinkHEADmaster
We want to add and delete rules with iptables(8), and manipulate set elements with nft(8). These are the first users we encounter sending multiple netlink messages in one sendmsg(). To support matching on those, we need to iterate over several messages, looking for a matching one, or a mismatching one (depending on quantifiers and match type), but we don't want to implement program loops because of security design reasons. We can't implement a generalised instruction that vectorises existing ones, either, because we need to support universal and existential quantifiers in fields that are repeated multiple times, once per each netlink message, with bitwise operations and non-exact matching types. Add vectorisation support to OP_CMP and OP_BITWISE instead, with a generic description for a vector (only sequences of netlink messages with length in nlmsghdr are supported at the moment) so that, depending on the quantifiers, we'll repeat those operations as many times as needed. This way, we don't risk any O(n^2) explosion, and we are bound by O(m * n) instead, with m compare/bitwise operations for a given expression, and n number of netlink messages. Add demos for nft and iptables using the new concepts. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/emit.h')
-rw-r--r--cooker/emit.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/cooker/emit.h b/cooker/emit.h
index abdeda9..7948071 100644
--- a/cooker/emit.h
+++ b/cooker/emit.h
@@ -19,20 +19,21 @@ void emit_load(struct gluten_ctx *g, struct gluten_offset dst,
struct gluten_offset emit_iovload(struct gluten_ctx *g,
struct gluten_offset iov,
struct gluten_offset iovlen,
- size_t len);
+ size_t alloc, size_t len);
void emit_store(struct gluten_ctx *g, struct gluten_offset dst,
struct gluten_offset src, struct gluten_offset count);
struct gluten_offset emit_seccomp_data(int index);
struct gluten_offset emit_bitwise(struct gluten_ctx *g, enum type type,
+ struct vec_desc *desc,
enum bitwise_type op_type,
struct gluten_offset dst,
struct gluten_offset x,
struct gluten_offset y);
-void emit_cmp(struct gluten_ctx *g, enum op_cmp_type cmp,
+void emit_cmp(struct gluten_ctx *g, enum op_cmp_type cmp, struct vec_desc *vec,
struct gluten_offset x, struct gluten_offset y, size_t size,
enum jump_type jmp);
void emit_cmp_field(struct gluten_ctx *g, enum op_cmp_type cmp,
- struct field *field,
+ struct vec_desc *vec, struct field *field,
struct gluten_offset base, struct gluten_offset match,
enum jump_type jmp);
void emit_return(struct gluten_ctx *g, struct gluten_offset v,