Skip to content

Commit b0db51d

Browse files
wenhao1006Gerrit Code Review
authored and
Gerrit Code Review
committed
Merge "trusty: Fuzzer for Confirmationui TA"
2 parents f28a604 + 0124a59 commit b0db51d

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

trusty/confirmationui/fuzz/Android.bp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (C) 2020 The Android Open Source Project
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
cc_fuzz {
16+
name: "trusty_confirmationui_fuzzer",
17+
defaults: ["trusty_fuzzer_defaults"],
18+
srcs: ["fuzz.cpp"],
19+
}

trusty/confirmationui/fuzz/fuzz.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (C) 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#undef NDEBUG
18+
19+
#include <assert.h>
20+
#include <log/log.h>
21+
#include <stdlib.h>
22+
#include <trusty/fuzz/utils.h>
23+
#include <unistd.h>
24+
25+
using android::trusty::fuzz::TrustyApp;
26+
27+
#define TIPC_DEV "/dev/trusty-ipc-dev0"
28+
#define CONFIRMATIONUI_PORT "com.android.trusty.confirmationui"
29+
30+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
31+
static uint8_t buf[TIPC_MAX_MSG_SIZE];
32+
33+
TrustyApp ta(TIPC_DEV, CONFIRMATIONUI_PORT);
34+
auto ret = ta.Connect();
35+
if (!ret.ok()) {
36+
android::trusty::fuzz::Abort();
37+
}
38+
39+
/* Send message to confirmationui server */
40+
ret = ta.Write(data, size);
41+
if (!ret.ok()) {
42+
return -1;
43+
}
44+
45+
/* Read message from confirmationui server */
46+
ret = ta.Read(&buf, sizeof(buf));
47+
if (!ret.ok()) {
48+
return -1;
49+
}
50+
51+
return 0;
52+
}

0 commit comments

Comments
 (0)