From 81b17ba1e4a991a96e93677eb5183561bf1f14b4 Mon Sep 17 00:00:00 2001 From: Martin Stein <martin.stein@genode-labs.com> Date: Fri, 15 Dec 2023 11:41:04 +0100 Subject: [PATCH] tresor_tester: check uninitialized vba data Adds a new command attribute "uninitialized_data" to the Tresor Tester configuration. If a <request op="read"> command has this attribute set to "yes" it assumes the read blocks to be uninitialized and therefore contain only 0's. Note, that a command that has "uninitialized_data" set to "yes" cannot have the attribute "salt". Ref #5077 --- repos/gems/run/tresor_tester.run | 3 +++ repos/gems/src/app/tresor_tester/main.cc | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/repos/gems/run/tresor_tester.run b/repos/gems/run/tresor_tester.run index e864e69b25..45a8c20989 100644 --- a/repos/gems/run/tresor_tester.run +++ b/repos/gems/run/tresor_tester.run @@ -257,6 +257,8 @@ append config { <log string="Step 2: test synchronous write, read"/> + + <request op="read" vba="1" num_blocks="1" uninitialized_data="yes"/> <request op="write" vba="1" num_blocks="1" salt="1234"/> <request op="read" vba="1" num_blocks="1" salt="1234"/> <request op="write" vba="12" num_blocks="10" /> @@ -402,6 +404,7 @@ append config { <log string="Step 9: test synchronous rekeying"/> + <request op="read" vba="30" num_blocks="10" uninitialized_data="yes"/> <request op="write" vba="0" num_blocks="1" salt="4359"/> <request op="rekey" sync="yes"/> <request op="read" vba="0" num_blocks="1" salt="4359"/> diff --git a/repos/gems/src/app/tresor_tester/main.cc b/repos/gems/src/app/tresor_tester/main.cc index b7190ee6b1..d644c0bce2 100644 --- a/repos/gems/src/app/tresor_tester/main.cc +++ b/repos/gems/src/app/tresor_tester/main.cc @@ -214,6 +214,7 @@ struct Tresor_tester::Request_node : Noncopyable bool const salt_avail; Salt const salt; Snapshot_id const snap_id; + bool const uninitialized_data; Operation read_op_attr(Xml_node const &node) { @@ -238,7 +239,8 @@ struct Tresor_tester::Request_node : Noncopyable sync(node.attribute_value("sync", false)), salt_avail(node.has_attribute("salt")), salt(node.attribute_value("salt", (Salt)0)), - snap_id(node.attribute_value("id", (Snapshot_id)0)) + snap_id(node.attribute_value("id", (Snapshot_id)0)), + uninitialized_data { node.attribute_value("uninitialized_data", false) } { } }; @@ -1010,14 +1012,17 @@ class Tresor_tester::Main : Vfs::Env::User, Client_data_interface, Crypto_key_fi _with_command(attr.in_req_tag, [&] (Command &cmd) { ASSERT(cmd.type == Command::REQUEST); Request_node const &node { *cmd.request_node }; - if (node.salt_avail) { - Tresor::Block gen_blk_data { }; + Tresor::Block gen_blk_data { }; + if (node.salt_avail) _generate_blk_data(gen_blk_data, attr.in_vba, node.salt); + else if (node.uninitialized_data) + memset(&gen_blk_data, 0, BLOCK_SIZE); + else + return; - if (memcmp(&attr.in_blk, &gen_blk_data, BLOCK_SIZE)) { - warning("client data mismatch: vba=", attr.in_vba, " req_tag=", attr.in_req_tag); - _num_errors++; - } + if (memcmp(&attr.in_blk, &gen_blk_data, BLOCK_SIZE)) { + warning("client data mismatch: vba=", attr.in_vba, " req_tag=", attr.in_req_tag); + _num_errors++; } }); if (_benchmark.constructed())