From e6f6defacae954f85cc7f4986d3bd0c14406ac0f Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Tue, 14 Feb 2012 12:45:01 +0100 Subject: [PATCH] Test capability integrity The test application tries to print a message using init's own LOG session without permission. This patch fixes #106. --- base/run/cap_integrity.run | 39 +++++++++++++++++++++++++++ base/src/test/cap_integrity/main.cc | 36 +++++++++++++++++++++++++ base/src/test/cap_integrity/target.mk | 3 +++ 3 files changed, 78 insertions(+) create mode 100644 base/run/cap_integrity.run create mode 100644 base/src/test/cap_integrity/main.cc create mode 100644 base/src/test/cap_integrity/target.mk diff --git a/base/run/cap_integrity.run b/base/run/cap_integrity.run new file mode 100644 index 000000000..81b8a5b0b --- /dev/null +++ b/base/run/cap_integrity.run @@ -0,0 +1,39 @@ +build "core init test/cap_integrity" + +create_boot_directory + +install_config { + + + + + + + + + + + + + + + + + + +} + +build_boot_image "core init test-cap_integrity" + +append qemu_args "-nographic -m 64" + +# increase expect buffer size, since there might be many log messages +match_max -d 100000 + +run_genode_until {child exited with exit value 0.*} 60 + +if {[regexp {\[init\] test message} $output]} { + exit -1 +} + +puts "Test succeeded" diff --git a/base/src/test/cap_integrity/main.cc b/base/src/test/cap_integrity/main.cc new file mode 100644 index 000000000..662970b65 --- /dev/null +++ b/base/src/test/cap_integrity/main.cc @@ -0,0 +1,36 @@ +/* + * \brief Testing capability integrity + * \author Christian Prochaska + * \date 2012-02-10 + * + */ + +/* + * Copyright (C) 2008-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include + +using namespace Genode; + +int main(int argc, char **argv) +{ + printf("--- capability integrity test ---\n"); + + /* try the first 1000 local name IDs */ + for (int local_name = 0; local_name < 1000; local_name++) { + Log_session_capability log_session_cap = + reinterpret_cap_cast(Native_capability(env()->ram_session_cap().dst(), local_name)); + Log_session_client log_session_client(log_session_cap); + try { + log_session_client.write("test message"); + } catch(...) { } + } + + printf("--- finished capability integrity test ---\n"); + return 0; +} diff --git a/base/src/test/cap_integrity/target.mk b/base/src/test/cap_integrity/target.mk new file mode 100644 index 000000000..024b16ca4 --- /dev/null +++ b/base/src/test/cap_integrity/target.mk @@ -0,0 +1,3 @@ +TARGET = test-cap_integrity +SRC_CC = main.cc +LIBS = env