diff options
author | Pawan Wagh <waghpawan@google.com> | 2023-02-17 22:57:53 +0000 |
---|---|---|
committer | Pawan Wagh <waghpawan@google.com> | 2023-02-27 03:14:51 +0000 |
commit | 7f3ca968798df346711f4152688d732161fedf4b (patch) | |
tree | 8ff2267f583cebea553072f23b50ef8ff07a6a63 /server | |
parent | 5d44be75962271af94e3d29a35f4bca2af3ff17e (diff) | |
download | netd-7f3ca968798df346711f4152688d732161fedf4b.tar.gz |
Fuzz NetdNativeService
Adding fuzzer using fuzzService API
Test: m netd_native_service_fuzzer && adb sync && adb shell /data/fuzz/x86_64/netd_native_service_fuzzer/netd_native_service_fuzzer
Bug: 232439428
Change-Id: I866b6078a5800d315c2426c7a7ae1dff00494f84
Diffstat (limited to 'server')
-rw-r--r-- | server/Android.bp | 12 | ||||
-rw-r--r-- | server/aidl-fuzzers/NetdNativeServiceFuzzer.cpp | 35 |
2 files changed, 47 insertions, 0 deletions
diff --git a/server/Android.bp b/server/Android.bp index 7f3202d9..ae871478 100644 --- a/server/Android.bp +++ b/server/Android.bp @@ -338,3 +338,15 @@ cc_fuzz { "aidl-fuzzers/NetdHwAidlServiceFuzzer.cpp", ], } + +cc_fuzz { + name: "netd_native_service_fuzzer", + defaults: [ + "service_fuzzer_defaults", + "netd_aidl_fuzzer_defaults", + ], + srcs: [ + "aidl-fuzzers/NetdNativeServiceFuzzer.cpp", + ], +} + diff --git a/server/aidl-fuzzers/NetdNativeServiceFuzzer.cpp b/server/aidl-fuzzers/NetdNativeServiceFuzzer.cpp new file mode 100644 index 00000000..2d041842 --- /dev/null +++ b/server/aidl-fuzzers/NetdNativeServiceFuzzer.cpp @@ -0,0 +1,35 @@ +/* + * 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. + */ + +#include <fuzzbinder/libbinder_driver.h> +#include <fuzzer/FuzzedDataProvider.h> + +#include "Permission.h" +#include "NetdConstants.h" +#include "NetdNativeService.h" + + +using android::fuzzService; +using android::net::NetdNativeService; + +std::mutex android::net::gBigNetdLock; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + auto service = new NetdNativeService(); + fuzzService(service, FuzzedDataProvider(data, size)); + + return 0; +} |