Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e865d885 authored by Tri Vo's avatar Tri Vo Committed by Gerrit Code Review
Browse files

Merge changes I06a7b475,Ic7a30b75,Ib22cf72b

* changes:
  trusty: Collect sancov file from confirmationui fuzzer
  trusty: coverage: Append .<pid>.sancov to sancov file names
  trusty: fuzz: Explicit errors instead of asserts
parents 5809095d 8da3ee71
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -14,10 +14,7 @@
 * limitations under the License.
 */

#undef NDEBUG

#include <assert.h>
#include <log/log.h>
#include <iostream>
#include <stdlib.h>
#include <trusty/coverage/coverage.h>
#include <trusty/fuzz/counters.h>
@@ -30,6 +27,7 @@ using android::trusty::fuzz::TrustyApp;

#define TIPC_DEV "/dev/trusty-ipc-dev0"
#define CONFIRMATIONUI_PORT "com.android.trusty.confirmationui"
#define CONFIRMATIONUI_MODULE_NAME "confirmationui.syms.elf"

/* ConfirmationUI TA's UUID is 7dee2364-c036-425b-b086-df0f6c233c1b */
static struct uuid confirmationui_uuid = {
@@ -48,11 +46,14 @@ struct data_packet {
    uint8_t payload[];
};

static CoverageRecord record(TIPC_DEV, &confirmationui_uuid);
static CoverageRecord record(TIPC_DEV, &confirmationui_uuid, CONFIRMATIONUI_MODULE_NAME);

extern "C" int LLVMFuzzerInitialize(int* /* argc */, char*** /* argv */) {
    auto ret = record.Open();
    assert(ret.ok());
    if (!ret.ok()) {
        std::cerr << ret.error() << std::endl;
        exit(-1);
    }
    return 0;
}

+3 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ namespace coverage {
using android::base::ErrnoError;
using android::base::Error;
using std::string;
using std::to_string;
using std::unique_ptr;

static inline uintptr_t RoundPageUp(uintptr_t val) {
@@ -54,11 +55,11 @@ CoverageRecord::CoverageRecord(string tipc_dev, struct uuid* uuid)
      shm_(NULL),
      shm_len_(0) {}

CoverageRecord::CoverageRecord(string tipc_dev, struct uuid* uuid, string sancov_filename)
CoverageRecord::CoverageRecord(string tipc_dev, struct uuid* uuid, string module_name)
    : tipc_dev_(std::move(tipc_dev)),
      coverage_srv_fd_(-1),
      uuid_(*uuid),
      sancov_filename_(sancov_filename),
      sancov_filename_(module_name + "." + to_string(getpid()) + ".sancov"),
      record_len_(0),
      shm_(NULL),
      shm_len_(0) {}
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class CoverageRecord {
     * Create a coverage record interface. On destruction, write this coverage
     * to the given sancov filename.
     */
    CoverageRecord(std::string tipc_dev, struct uuid* uuid, std::string sancov_filename);
    CoverageRecord(std::string tipc_dev, struct uuid* uuid, std::string module_name);

    ~CoverageRecord();
    Result<void> Open();
+5 −5
Original line number Diff line number Diff line
@@ -14,15 +14,12 @@
 * limitations under the License.
 */

#undef NDEBUG

#include <assert.h>
#include <log/log.h>
#include <stdlib.h>
#include <trusty/coverage/coverage.h>
#include <trusty/fuzz/counters.h>
#include <trusty/fuzz/utils.h>
#include <unistd.h>
#include <iostream>

using android::trusty::coverage::CoverageRecord;
using android::trusty::fuzz::ExtraCounters;
@@ -43,7 +40,10 @@ static CoverageRecord record(TIPC_DEV, &test_srv_uuid);

extern "C" int LLVMFuzzerInitialize(int* /* argc */, char*** /* argv */) {
    auto ret = record.Open();
    assert(ret.ok());
    if (!ret.ok()) {
        std::cerr << ret.error() << std::endl;
        exit(-1);
    }
    return 0;
}

+5 −5
Original line number Diff line number Diff line
@@ -14,15 +14,12 @@
 * limitations under the License.
 */

#undef NDEBUG

#include <assert.h>
#include <log/log.h>
#include <stdlib.h>
#include <trusty/coverage/coverage.h>
#include <trusty/fuzz/counters.h>
#include <trusty/fuzz/utils.h>
#include <unistd.h>
#include <iostream>

using android::trusty::coverage::CoverageRecord;
using android::trusty::fuzz::ExtraCounters;
@@ -44,7 +41,10 @@ static CoverageRecord record(TIPC_DEV, &gatekeeper_uuid, GATEKEEPER_MODULE_NAME)

extern "C" int LLVMFuzzerInitialize(int* /* argc */, char*** /* argv */) {
    auto ret = record.Open();
    assert(ret.ok());
    if (!ret.ok()) {
        std::cerr << ret.error() << std::endl;
        exit(-1);
    }
    return 0;
}

Loading