AuthGraph: add fuzzer

Test: m android.hardware.authgraph-service.nonsecure_fuzzer
Bug: 284470121
Change-Id: Ib702b5b0cf69a4a839326297c2d71355562b46c3
This commit is contained in:
David Drysdale
2023-11-06 13:23:11 +00:00
parent 6c09af215d
commit 6fb22dc9ef
2 changed files with 48 additions and 0 deletions

View File

@@ -63,3 +63,20 @@ rust_binary {
"src/main.rs",
],
}
rust_fuzz {
name: "android.hardware.authgraph-service.nonsecure_fuzzer",
rustlibs: [
"libauthgraph_hal",
"libauthgraph_nonsecure",
"libbinder_random_parcel_rs",
"libbinder_rs",
],
srcs: ["src/fuzzer.rs"],
fuzz_config: {
cc: [
"drysdale@google.com",
"hasinitg@google.com",
],
},
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#![allow(missing_docs)]
#![no_main]
extern crate libfuzzer_sys;
use authgraph_hal::service::AuthGraphService;
use authgraph_nonsecure::LocalTa;
use binder_random_parcel_rs::fuzz_service;
use libfuzzer_sys::fuzz_target;
use std::sync::{Arc, Mutex};
fuzz_target!(|data: &[u8]| {
let local_ta = LocalTa::new();
let service = AuthGraphService::new_as_binder(Arc::new(Mutex::new(local_ta)));
fuzz_service(&mut service.as_binder(), data);
});