Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG REGISTRY="docker.io"
ARG BASE_IMAGE="${REGISTRY}/ubuntu:22.04"
ARG VPN_VERSION="1.0.25"
ARG BUSYBOX_VERSION="0.0.15"
ARG LINUX_VERSION="3.5.18-beta"
ARG LINUX_VERSION="3.5.25-beta"
ARG IGLOO_DRIVER_VERSION="0.0.59"
ARG LIBNVRAM_VERSION="0.0.24"
ARG CONSOLE_VERSION="1.0.7"
Expand Down
66 changes: 66 additions & 0 deletions pyplugins/testing/task_size_verify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from penguin import Plugin, plugins
import os


class TaskSizeVerify(Plugin):
def __init__(self):
super().__init__()
self.outdir = self.get_arg("outdir")
self.conf = self.get_arg("conf")

@plugins.syscalls.syscall("on_sys_ioctl_return", comm_filter="send_syscall",
arg_filters=[0x17, 0x1234])
def verify_task_size(self, regs, proto, syscall, fd, op, arg):
self.logger.info("TaskSizeVerify: Triggered")

# Get expected task size from config context
expected_str = self.conf.get('env', {}).get('igloo_task_size')
if not expected_str:
self.logger.error("TaskSizeVerify: No igloo_task_size in config!")
return

expected = int(expected_str, 16)

# Get actual task size via OSI
proc = yield from plugins.osi.get_proc()
if not proc:
self.logger.error("TaskSizeVerify: Could not get proc info")
return

actual = proc.task_size
self.logger.info(
f"TaskSizeVerify: Expected={expected:#x}, Actual={actual:#x}")

# Also check mappings to ensure nothing is above the limit
mappings = yield from plugins.osi.get_mappings()
max_addr = 0
if mappings:
for m in mappings:
if m.end > max_addr:
max_addr = m.end

self.logger.info(f"TaskSizeVerify: Max mapping end={max_addr:#x}")

passed = True
if actual != expected:
self.logger.error(
f"TaskSizeVerify: FAIL - actual task_size {actual:#x} != expected {expected:#x}")
passed = False

if max_addr > expected:
self.logger.error(
f"TaskSizeVerify: FAIL - mapping end {max_addr:#x} exceeds task_size {expected:#x}")
passed = False
for m in mappings:
self.logger.info(
f"Mapping: {m.start:#x} - {m.end:#x} {m.name}")

result = "passed" if passed else "failed"

with open(os.path.join(self.outdir, "task_size_test.txt"), "w") as f:
f.write(f"Task size test: {result}\n")
if not passed:
f.write(
f"Actual: {actual:#x}, Expected: {expected:#x}, Max Mapping: {max_addr:#x}\n")

syscall.retval = 0 if passed else 1
1 change: 1 addition & 0 deletions tests/unit_tests/test_target/base_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ patches:
- ./patches/tests/mtd_test.yaml
- ./patches/tests/anonfs.yaml
- ./patches/tests/pseudofiles_comprehensive.yaml
- ./patches/tests/task_size.yaml
# - ./patches/tests/uboot_env_cmp.yaml


Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/aarch64.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: aarch64

env:
igloo_task_size: "0x4000000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/aarch64/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/armel.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: armel

env:
igloo_task_size: "0x7f000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/armel/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/loongarch64.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: loongarch64

env:
igloo_task_size: "0x4000000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/loongarch64/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/mips64eb.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: mips64eb

env:
igloo_task_size: "0x4000000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/mips64eb/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/mips64el.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: mips64el

env:
igloo_task_size: "0x4000000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/mips64el/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/mipseb.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: mipseb

env:
igloo_task_size: "0x7f000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/mipseb/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/mipsel.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: mipsel

env:
igloo_task_size: "0x7f000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/mipsel/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/powerpc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: powerpc

env:
igloo_task_size: "0x7f000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/powerpc/*
Expand Down
8 changes: 5 additions & 3 deletions tests/unit_tests/test_target/patches/arches/powerpc64.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
core:
arch: powerpc64
arch: powerpc64

static_files:
/igloo/utils/*:
env:
igloo_task_size: "0x4000000000"

static_files: /igloo/utils/*:
host_path: /igloo_static/powerpc64/*
mode: 493
type: host_file
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/riscv64.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: riscv64

env:
igloo_task_size: "0x4000000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/riscv64/*
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/test_target/patches/arches/x86_64.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
core:
arch: intel64

env:
igloo_task_size: "0x4000000000"

static_files:
/igloo/utils/*:
host_path: /igloo_static/x86_64/*
Expand Down
26 changes: 26 additions & 0 deletions tests/unit_tests/test_target/patches/tests/task_size.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins:
task_size_verify: {}
verifier:
conditions:
task_size_enforcement:
type: file_contains
file: task_size_test.txt
string: "Task size test: passed"

static_files:
/tests/task_size.sh:
type: inline_file
contents: |
#!/igloo/utils/sh
set -x

# Trigger verification via a specific ioctl call
/igloo/utils/send_syscall ioctl 0x17 0x1234

if [ $? -eq 0 ]; then
echo "Task size verification passed"
else
echo "Task size verification failed"
exit 1
fi
mode: 755
Loading