From 6fb22dc9ef6e481ef6d37205f279f386871a5d4d Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Mon, 6 Nov 2023 13:23:11 +0000 Subject: [PATCH] AuthGraph: add fuzzer Test: m android.hardware.authgraph-service.nonsecure_fuzzer Bug: 284470121 Change-Id: Ib702b5b0cf69a4a839326297c2d71355562b46c3 --- security/authgraph/default/Android.bp | 17 +++++++++++++ security/authgraph/default/src/fuzzer.rs | 31 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 security/authgraph/default/src/fuzzer.rs diff --git a/security/authgraph/default/Android.bp b/security/authgraph/default/Android.bp index ac67136ada..c4810759ec 100644 --- a/security/authgraph/default/Android.bp +++ b/security/authgraph/default/Android.bp @@ -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", + ], + }, +} diff --git a/security/authgraph/default/src/fuzzer.rs b/security/authgraph/default/src/fuzzer.rs new file mode 100644 index 0000000000..6a9cfdd0b6 --- /dev/null +++ b/security/authgraph/default/src/fuzzer.rs @@ -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); +});