Merge changes Id77b87bb,I56a15c80 am: 9763f21565
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1504100 Change-Id: I2a538361453c7f5039b810d63b9e68b1323cd454
This commit is contained in:
commit
0b1ef96898
3 changed files with 19 additions and 24 deletions
|
@ -14,10 +14,8 @@
|
|||
|
||||
cc_defaults {
|
||||
name: "trusty_fuzzer_defaults",
|
||||
static_libs: [
|
||||
"libtrusty_fuzz_utils",
|
||||
],
|
||||
shared_libs: [
|
||||
"libtrusty_fuzz_utils",
|
||||
"libbase",
|
||||
"liblog",
|
||||
],
|
||||
|
@ -36,6 +34,7 @@ cc_library {
|
|||
srcs: ["utils.cpp"],
|
||||
export_include_dirs: ["include"],
|
||||
shared_libs: [
|
||||
"libtrusty_test",
|
||||
"libbase",
|
||||
"liblog",
|
||||
],
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <linux/uio.h>
|
||||
#include <log/log_read.h>
|
||||
#include <time.h>
|
||||
#include <trusty/tipc.h>
|
||||
#include <iostream>
|
||||
|
||||
using android::base::ErrnoError;
|
||||
|
@ -32,9 +33,6 @@ using android::base::Error;
|
|||
using android::base::Result;
|
||||
using android::base::unique_fd;
|
||||
|
||||
#define TIPC_IOC_MAGIC 'r'
|
||||
#define TIPC_IOC_CONNECT _IOW(TIPC_IOC_MAGIC, 0x80, char*)
|
||||
|
||||
namespace {
|
||||
|
||||
const size_t kTimeoutSeconds = 5;
|
||||
|
@ -80,27 +78,14 @@ TrustyApp::TrustyApp(std::string tipc_dev, std::string ta_port)
|
|||
: tipc_dev_(tipc_dev), ta_port_(ta_port), ta_fd_(-1) {}
|
||||
|
||||
Result<void> TrustyApp::Connect() {
|
||||
/*
|
||||
* TODO: We can't use libtrusty because (yet)
|
||||
* (1) cc_fuzz can't deal with vendor components (b/170753563)
|
||||
* (2) We need non-blocking behavior to detect Trusty going down.
|
||||
* (we could implement the timeout in the fuzzing code though, as
|
||||
* it needs to be around the call to read())
|
||||
*/
|
||||
alarm(kTimeoutSeconds);
|
||||
int fd = open(tipc_dev_.c_str(), O_RDWR);
|
||||
int fd = tipc_connect(tipc_dev_.c_str(), ta_port_.c_str());
|
||||
alarm(0);
|
||||
if (fd < 0) {
|
||||
return ErrnoError() << "failed to open TIPC device: ";
|
||||
}
|
||||
ta_fd_.reset(fd);
|
||||
|
||||
// This ioctl will time out in the kernel if it can't connect.
|
||||
int rc = TEMP_FAILURE_RETRY(ioctl(ta_fd_, TIPC_IOC_CONNECT, ta_port_.c_str()));
|
||||
if (rc < 0) {
|
||||
return ErrnoError() << "failed to connect to TIPC service: ";
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
cc_library {
|
||||
name: "libtrusty",
|
||||
vendor: true,
|
||||
|
||||
cc_defaults {
|
||||
name: "libtrusty_defaults",
|
||||
srcs: ["trusty.c"],
|
||||
export_include_dirs: ["include"],
|
||||
cflags: [
|
||||
|
@ -25,3 +23,16 @@ cc_library {
|
|||
|
||||
shared_libs: ["liblog"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libtrusty",
|
||||
vendor: true,
|
||||
defaults: ["libtrusty_defaults"],
|
||||
}
|
||||
|
||||
// TODO(b/170753563): cc_fuzz can't deal with vendor components. Build libtrusty
|
||||
// for system.
|
||||
cc_test_library {
|
||||
name: "libtrusty_test",
|
||||
defaults: ["libtrusty_defaults"],
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue