From 4a1430ac3c60b5ff1c00bf98c004351c67c26c23 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Mon, 19 Jun 2023 14:28:45 +0200 Subject: Update demos --- demo/bpf | Bin 0 -> 56 bytes demo/connect.bpf | Bin 0 -> 56 bytes demo/connect.gluten | Bin 0 -> 262144 bytes demo/connect1.hjson | 8 +++++++ demo/eater.pid | 1 + demo/ioctl.bpf | Bin 0 -> 56 bytes demo/ioctl.gluten | Bin 0 -> 262144 bytes demo/mknod. | Bin 0 -> 72 bytes demo/mknod.bpf | Bin 0 -> 72 bytes demo/mknod.gluten | Bin 0 -> 262144 bytes demo/mknod.hjson | 2 +- demo/mknod.hjson.bak | 33 ++++++++++++++++++++++++++ demo/mknod_cont.hjson | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ demo/read.bpf | Bin 0 -> 56 bytes demo/read.gluten | Bin 0 -> 262144 bytes demo/socket.bpf | Bin 0 -> 80 bytes demo/socket.gluten | Bin 0 -> 262144 bytes demo/socket.hjson | 11 +++++---- 18 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 demo/bpf create mode 100644 demo/connect.bpf create mode 100644 demo/connect.gluten create mode 100644 demo/connect1.hjson create mode 100644 demo/eater.pid create mode 100644 demo/ioctl.bpf create mode 100644 demo/ioctl.gluten create mode 100644 demo/mknod. create mode 100644 demo/mknod.bpf create mode 100644 demo/mknod.gluten create mode 100644 demo/mknod.hjson.bak create mode 100644 demo/mknod_cont.hjson create mode 100644 demo/read.bpf create mode 100644 demo/read.gluten create mode 100644 demo/socket.bpf create mode 100644 demo/socket.gluten diff --git a/demo/bpf b/demo/bpf new file mode 100644 index 0000000..ad1fbf9 Binary files /dev/null and b/demo/bpf differ diff --git a/demo/connect.bpf b/demo/connect.bpf new file mode 100644 index 0000000..ad1fbf9 Binary files /dev/null and b/demo/connect.bpf differ diff --git a/demo/connect.gluten b/demo/connect.gluten new file mode 100644 index 0000000..0a66814 Binary files /dev/null and b/demo/connect.gluten differ diff --git a/demo/connect1.hjson b/demo/connect1.hjson new file mode 100644 index 0000000..3469fc2 --- /dev/null +++ b/demo/connect1.hjson @@ -0,0 +1,8 @@ +[ + { /* fake connect syscall */ + "match": [ + { "connect": { "addr": { "family": "unix", "path": "/fake.sock" } } } + ], + "return": 0 + } +] diff --git a/demo/eater.pid b/demo/eater.pid new file mode 100644 index 0000000..d449e42 --- /dev/null +++ b/demo/eater.pid @@ -0,0 +1 @@ +19188 diff --git a/demo/ioctl.bpf b/demo/ioctl.bpf new file mode 100644 index 0000000..3064f8b Binary files /dev/null and b/demo/ioctl.bpf differ diff --git a/demo/ioctl.gluten b/demo/ioctl.gluten new file mode 100644 index 0000000..df179c5 Binary files /dev/null and b/demo/ioctl.gluten differ diff --git a/demo/mknod. b/demo/mknod. new file mode 100644 index 0000000..500cbce Binary files /dev/null and b/demo/mknod. differ diff --git a/demo/mknod.bpf b/demo/mknod.bpf new file mode 100644 index 0000000..500cbce Binary files /dev/null and b/demo/mknod.bpf differ diff --git a/demo/mknod.gluten b/demo/mknod.gluten new file mode 100644 index 0000000..13fdaeb Binary files /dev/null and b/demo/mknod.gluten differ diff --git a/demo/mknod.hjson b/demo/mknod.hjson index 40b5b8b..9124a8a 100644 --- a/demo/mknod.hjson +++ b/demo/mknod.hjson @@ -1,6 +1,6 @@ [ { - "match": [ /* Giuseppe's example */ + "match": [ { "mknodat": { "path": { "tag": "path" }, "mode": { "tag": "mode" }, diff --git a/demo/mknod.hjson.bak b/demo/mknod.hjson.bak new file mode 100644 index 0000000..7055aee --- /dev/null +++ b/demo/mknod.hjson.bak @@ -0,0 +1,33 @@ +[ + { + "match": [ /* Giuseppe's example */ + { "mknodat": + { "path": { "tag": "path" }, + "mode": { "tag": "mode" }, + "type": { "tag": "type" }, + "major": 1, + "minor": { "value": { "in": [ 3, 5, 7, 8, 9 ] }, "tag": "minor" } + } + }, + { "mknod": + { "path": { "tag": "path" }, + "mode": { "tag": "mode" }, + "type": { "tag": "type" }, + "major": 1, + "minor": { "value": { "in": [ 3, 5, 7, 8, 9 ] }, "tag": "minor" } + } + } + ], + "call": + { "mknod": + { "path": { "tag": { "get": "path" } }, + "mode": { "tag": { "get": "mode" } }, + "type": { "tag": { "get": "type" } }, + "major": 1, + "minor": { "tag": { "get": "minor" } } + }, + "context": { "mnt": "caller" } + }, + "return": { "value": 0 } + } +] diff --git a/demo/mknod_cont.hjson b/demo/mknod_cont.hjson new file mode 100644 index 0000000..71f41d0 --- /dev/null +++ b/demo/mknod_cont.hjson @@ -0,0 +1,63 @@ +[ + { + "match": [ + { "mknodat": + { "path": { "tag": "path" }, + "mode": { "tag": "mode" }, + "type": { "tag": "type" }, + "major": 1, + "minor": { "value": { "in": [ 3, 5, 7, 8, 9 ] }, "tag": "minor" } + } + }, + { "mknod": + { "path": { "tag": "path" }, + "mode": { "tag": "mode" }, + "type": { "tag": "type" }, + "major": 1, + "minor": { "value": { "in": [ 3, 5, 7, 8, 9 ] }, "tag": "minor" } + } + } + ], + "call": + { "mknod": + { "path": { "tag": { "get": "path" } }, + "mode": { "tag": { "get": "mode" } }, + "type": { "tag": { "get": "type" } }, + "major": 1, + "minor": { "tag": { "get": "minor" } } + }, + "ret": "x", + "context": { "user": "init", "mnt": "caller" } + }, + "return": { "tag": "x" } + } +] + +/* + * INTFLAGS, LONGFLAGS, U32FLAGS + * + * "field": { "in": [ "ipc", "mount", "uts" ] } + * flags & set + * !!(flags & (ipc | mount | ns)) + * + * "field": { "all": [ "ipc", "mount", "uts" ] } + * flags & set == set + * flags & (ipc | mount | ns) == (ipc | mount | ns) + * + * "field": { "not": [ "ipc", "mount", "uts" ] } + * !(flags & set) + * + * "field": { "ipc": false, "mount": true, "uts": false } + * flags & set == set + * !(flags & ipc) && (flags & mount) && !(flags & utc) + * + * "field": { "ipc" } + * flags == ipc + * + * INTMASK + * value = (target value & known values) + * + * INT, LONG, U32 + * "arg": { "in": [ 0, 1 ] } + * arg == 0 || arg == 1 + */ diff --git a/demo/read.bpf b/demo/read.bpf new file mode 100644 index 0000000..53eb58f Binary files /dev/null and b/demo/read.bpf differ diff --git a/demo/read.gluten b/demo/read.gluten new file mode 100644 index 0000000..eff29c4 Binary files /dev/null and b/demo/read.gluten differ diff --git a/demo/socket.bpf b/demo/socket.bpf new file mode 100644 index 0000000..0d4a8f1 Binary files /dev/null and b/demo/socket.bpf differ diff --git a/demo/socket.gluten b/demo/socket.gluten new file mode 100644 index 0000000..1c45e12 Binary files /dev/null and b/demo/socket.gluten differ diff --git a/demo/socket.hjson b/demo/socket.hjson index d9a3345..c5ddfdb 100644 --- a/demo/socket.hjson +++ b/demo/socket.hjson @@ -1,11 +1,14 @@ [ { "match": [ - { "socket": { "family": "unix", "type": "stream", "flags": "cloexec", "protocol": 0 } } + { "socket": { "family": "unix" } } ], - "call": [ - { "socket": { "family": "unix", "type": "stream", "flags": [ "cloexec", "nonblock" ], "protocol": 0 }, "ret": "new_fd" } + "return": {"continue": true } + }, + { + "match": [ + { "socket": {} } ], - "fd": { "src": { "tag": "new_fd" }, "close_on_exec": false, "return": true } + "return": {"error": -1, "value": 0 } } ] -- cgit v1.2.3