Loading automotive/audiocontrol/1.0/default/Android.bp +14 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ cc_binary { relative_install_path: "hw", srcs: [ "AudioControl.cpp", "service.cpp" "service.cpp", ], init_rc: ["android.hardware.automotive.audiocontrol@1.0-service.rc"], Loading @@ -40,3 +40,16 @@ cc_binary { ], vintf_fragments: ["audiocontrol_manifest.xml"], } filegroup { name: "audiocontrolV1.0_source", srcs: [ "AudioControl.cpp", ], } cc_library_headers { name: "audiocontrolV1.0_header", host_supported: true, export_include_dirs: ["."], } automotive/audiocontrol/1.0/default/test/fuzzer/Android.bp 0 → 100644 +52 −0 Original line number Diff line number Diff line /****************************************************************************** * * Copyright (C) 2021 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. * ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ package { // See: http://go/android-license-faq // A large-scale-change added 'default_applicable_licenses' to import // all of the 'license_kinds' from "hardware_interfaces_license" // to get the below license kinds: // SPDX-license-identifier-Apache-2.0 default_applicable_licenses: ["hardware_interfaces_license"], } cc_fuzz { name: "audiocontrolV1.0_fuzzer", host_supported: true, srcs: [ "audiocontrolV1.0_fuzzer.cpp", ":audiocontrolV1.0_source", ], header_libs: [ "audiocontrolV1.0_header", ], shared_libs: [ "android.hardware.automotive.audiocontrol@1.0", "libhidlbase", "liblog", "libutils", ], fuzz_config: { cc: [ "android-media-fuzzing-reports@google.com", ], componentid: 533764, }, } automotive/audiocontrol/1.0/default/test/fuzzer/audiocontrolV1.0_fuzzer.cpp 0 → 100644 +41 −0 Original line number Diff line number Diff line /****************************************************************************** * * Copyright (C) 2021 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. * ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <AudioControl.h> #include <fuzzer/FuzzedDataProvider.h> using ::android::sp; using ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber; using ::android::hardware::automotive::audiocontrol::V1_0::implementation::AudioControl; namespace android::hardware::automotive::audiocontrol::V1_0::implementation::fuzzer { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (size < 1) { return 0; } if (sp<AudioControl> audioControl = new AudioControl(); audioControl != nullptr) { FuzzedDataProvider fdp = FuzzedDataProvider(data, size); ContextNumber contextNumber = static_cast<ContextNumber>(fdp.ConsumeIntegral<uint32_t>()); audioControl->getBusForContext(contextNumber); audioControl->setBalanceTowardRight(fdp.ConsumeFloatingPoint<float>()); audioControl->setFadeTowardFront(fdp.ConsumeFloatingPoint<float>()); } return 0; } } // namespace android::hardware::automotive::audiocontrol::V1_0::implementation::fuzzer automotive/vehicle/2.0/default/Android.bp +26 −0 Original line number Diff line number Diff line Loading @@ -221,3 +221,29 @@ cc_binary { "android.hardware.automotive.vehicle@2.0-libproto-native", ], } cc_fuzz { name: "vehicleManager_fuzzer", vendor: true, defaults: ["vhal_v2_0_target_defaults"], whole_static_libs: ["android.hardware.automotive.vehicle@2.0-manager-lib"], srcs: [ "tests/fuzzer/VehicleManager_fuzzer.cpp", ], shared_libs: [ "libbase", "libcutils", "libbinder_ndk", ], header_libs: ["libbase_headers"], local_include_dirs: [ "common/include", "tests", ], fuzz_config: { cc: [ "android-media-fuzzing-reports@google.com", ], componentid: 533764, }, } automotive/vehicle/2.0/default/tests/fuzzer/README.md 0 → 100644 +66 −0 Original line number Diff line number Diff line # Fuzzer for android.hardware.automotive.vehicle@2.0-manager-lib ## Plugin Design Considerations The fuzzer plugin for android.hardware.automotive.vehicle@2.0-manager-lib is designed based on the understanding of the library and tries to achieve the following: ##### Maximize code coverage The configuration parameters are not hardcoded, but instead selected based on incoming data. This ensures more code paths are reached by the fuzzer. Vehicle Manager supports the following parameters: 1. Vehicle Property (parameter name: `vehicleProp`) 2. Diagnostic Integer Sensor Index (parameter name: `diagnosticIntIndex`) 3. Diagnostic Float Sensor Index (parameter name: `diagnosticFloatIndex`) 4. Availability Message Type (parameter name: `availabilityMsgType`) 5. Subscription Message Type (parameter name: `subscriptionMsgType`) | Parameter| Valid Values| Configured Value| |------------- |-------------| ----- | | `vehicleProp` | 0.`VehicleProperty::INVALID` 1.`VehicleProperty::HVAC_FAN_SPEED` 2.`VehicleProperty::INFO_MAKE` 3.`VehicleProperty::DISPLAY_BRIGHTNESS` 4.`VehicleProperty::INFO_FUEL_CAPACITY` 5.`VehicleProperty::HVAC_SEAT_TEMPERATURE`| Value obtained from FuzzedDataProvider | | `diagnosticIntIndex` | 0.`DiagnosticIntegerSensorIndex::FUEL_SYSTEM_STATUS` 1.`DiagnosticIntegerSensorIndex::MALFUNCTION_INDICATOR_LIGHT_ON` 2.`DiagnosticIntegerSensorIndex::NUM_OXYGEN_SENSORS_PRESENT` 3.`DiagnosticIntegerSensorIndex::FUEL_TYPE` | Value obtained from FuzzedDataProvider | | `diagnosticFloatIndex` | 0.`DiagnosticFloatSensorIndex::CALCULATED_ENGINE_LOAD` 1.`DiagnosticFloatSensorIndex::SHORT_TERM_FUEL_TRIM_BANK1` 2.`DiagnosticFloatSensorIndex::LONG_TERM_FUEL_TRIM_BANK1` 3.`DiagnosticFloatSensorIndex::THROTTLE_POSITION` | Value obtained from FuzzedDataProvider | | `availabilityMsgType` | 0.`VmsMessageType::AVAILABILITY_CHANGE` 1.`VmsMessageType::AVAILABILITY_RESPONSE` | Value obtained from FuzzedDataProvider | | `subscriptionMsgType` | 0.`VmsMessageType::SUBSCRIPTIONS_CHANGE` 1.`VmsMessageType::SUBSCRIPTIONS_RESPONSE` | Value obtained from FuzzedDataProvider | This also ensures that the plugin is always deterministic for any given input. ## Build This describes steps to build vehicleManager_fuzzer binary. ### Android #### Steps to build Build the fuzzer ``` $ mm -j$(nproc) vehicleManager_fuzzer ``` #### Steps to run Create a directory CORPUS_DIR ``` $ adb shell mkdir /data/local/tmp/CORPUS_DIR ``` ##### Some Additional steps needed to run the vehicleManager_fuzzer successfully on device 1. Push the following libraries from /vendor/lib/ and /vendor/lib64/ folders of your workspace to the device's /vendor/lib/ and /vendor/lib64/ : ``` 1.1 android.hardware.automotive.vehicle@2.0.so 1.2 carwatchdog_aidl_interface-V2-ndk_platform.so ``` 2. Now, reboot the device using command ``` $ adb reboot ``` ##### To run the fuzzer on device ``` $ adb sync data $ adb shell LD_LIBRARY_PATH=/vendor/lib64 /data/fuzz/${TARGET_ARCH}/vehicleManager_fuzzer/vendor/vehicleManager_fuzzer /data/local/tmp/CORPUS_DIR ``` ## References: * http://llvm.org/docs/LibFuzzer.html * https://github.com/google/oss-fuzz Loading
automotive/audiocontrol/1.0/default/Android.bp +14 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ cc_binary { relative_install_path: "hw", srcs: [ "AudioControl.cpp", "service.cpp" "service.cpp", ], init_rc: ["android.hardware.automotive.audiocontrol@1.0-service.rc"], Loading @@ -40,3 +40,16 @@ cc_binary { ], vintf_fragments: ["audiocontrol_manifest.xml"], } filegroup { name: "audiocontrolV1.0_source", srcs: [ "AudioControl.cpp", ], } cc_library_headers { name: "audiocontrolV1.0_header", host_supported: true, export_include_dirs: ["."], }
automotive/audiocontrol/1.0/default/test/fuzzer/Android.bp 0 → 100644 +52 −0 Original line number Diff line number Diff line /****************************************************************************** * * Copyright (C) 2021 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. * ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ package { // See: http://go/android-license-faq // A large-scale-change added 'default_applicable_licenses' to import // all of the 'license_kinds' from "hardware_interfaces_license" // to get the below license kinds: // SPDX-license-identifier-Apache-2.0 default_applicable_licenses: ["hardware_interfaces_license"], } cc_fuzz { name: "audiocontrolV1.0_fuzzer", host_supported: true, srcs: [ "audiocontrolV1.0_fuzzer.cpp", ":audiocontrolV1.0_source", ], header_libs: [ "audiocontrolV1.0_header", ], shared_libs: [ "android.hardware.automotive.audiocontrol@1.0", "libhidlbase", "liblog", "libutils", ], fuzz_config: { cc: [ "android-media-fuzzing-reports@google.com", ], componentid: 533764, }, }
automotive/audiocontrol/1.0/default/test/fuzzer/audiocontrolV1.0_fuzzer.cpp 0 → 100644 +41 −0 Original line number Diff line number Diff line /****************************************************************************** * * Copyright (C) 2021 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. * ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <AudioControl.h> #include <fuzzer/FuzzedDataProvider.h> using ::android::sp; using ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber; using ::android::hardware::automotive::audiocontrol::V1_0::implementation::AudioControl; namespace android::hardware::automotive::audiocontrol::V1_0::implementation::fuzzer { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (size < 1) { return 0; } if (sp<AudioControl> audioControl = new AudioControl(); audioControl != nullptr) { FuzzedDataProvider fdp = FuzzedDataProvider(data, size); ContextNumber contextNumber = static_cast<ContextNumber>(fdp.ConsumeIntegral<uint32_t>()); audioControl->getBusForContext(contextNumber); audioControl->setBalanceTowardRight(fdp.ConsumeFloatingPoint<float>()); audioControl->setFadeTowardFront(fdp.ConsumeFloatingPoint<float>()); } return 0; } } // namespace android::hardware::automotive::audiocontrol::V1_0::implementation::fuzzer
automotive/vehicle/2.0/default/Android.bp +26 −0 Original line number Diff line number Diff line Loading @@ -221,3 +221,29 @@ cc_binary { "android.hardware.automotive.vehicle@2.0-libproto-native", ], } cc_fuzz { name: "vehicleManager_fuzzer", vendor: true, defaults: ["vhal_v2_0_target_defaults"], whole_static_libs: ["android.hardware.automotive.vehicle@2.0-manager-lib"], srcs: [ "tests/fuzzer/VehicleManager_fuzzer.cpp", ], shared_libs: [ "libbase", "libcutils", "libbinder_ndk", ], header_libs: ["libbase_headers"], local_include_dirs: [ "common/include", "tests", ], fuzz_config: { cc: [ "android-media-fuzzing-reports@google.com", ], componentid: 533764, }, }
automotive/vehicle/2.0/default/tests/fuzzer/README.md 0 → 100644 +66 −0 Original line number Diff line number Diff line # Fuzzer for android.hardware.automotive.vehicle@2.0-manager-lib ## Plugin Design Considerations The fuzzer plugin for android.hardware.automotive.vehicle@2.0-manager-lib is designed based on the understanding of the library and tries to achieve the following: ##### Maximize code coverage The configuration parameters are not hardcoded, but instead selected based on incoming data. This ensures more code paths are reached by the fuzzer. Vehicle Manager supports the following parameters: 1. Vehicle Property (parameter name: `vehicleProp`) 2. Diagnostic Integer Sensor Index (parameter name: `diagnosticIntIndex`) 3. Diagnostic Float Sensor Index (parameter name: `diagnosticFloatIndex`) 4. Availability Message Type (parameter name: `availabilityMsgType`) 5. Subscription Message Type (parameter name: `subscriptionMsgType`) | Parameter| Valid Values| Configured Value| |------------- |-------------| ----- | | `vehicleProp` | 0.`VehicleProperty::INVALID` 1.`VehicleProperty::HVAC_FAN_SPEED` 2.`VehicleProperty::INFO_MAKE` 3.`VehicleProperty::DISPLAY_BRIGHTNESS` 4.`VehicleProperty::INFO_FUEL_CAPACITY` 5.`VehicleProperty::HVAC_SEAT_TEMPERATURE`| Value obtained from FuzzedDataProvider | | `diagnosticIntIndex` | 0.`DiagnosticIntegerSensorIndex::FUEL_SYSTEM_STATUS` 1.`DiagnosticIntegerSensorIndex::MALFUNCTION_INDICATOR_LIGHT_ON` 2.`DiagnosticIntegerSensorIndex::NUM_OXYGEN_SENSORS_PRESENT` 3.`DiagnosticIntegerSensorIndex::FUEL_TYPE` | Value obtained from FuzzedDataProvider | | `diagnosticFloatIndex` | 0.`DiagnosticFloatSensorIndex::CALCULATED_ENGINE_LOAD` 1.`DiagnosticFloatSensorIndex::SHORT_TERM_FUEL_TRIM_BANK1` 2.`DiagnosticFloatSensorIndex::LONG_TERM_FUEL_TRIM_BANK1` 3.`DiagnosticFloatSensorIndex::THROTTLE_POSITION` | Value obtained from FuzzedDataProvider | | `availabilityMsgType` | 0.`VmsMessageType::AVAILABILITY_CHANGE` 1.`VmsMessageType::AVAILABILITY_RESPONSE` | Value obtained from FuzzedDataProvider | | `subscriptionMsgType` | 0.`VmsMessageType::SUBSCRIPTIONS_CHANGE` 1.`VmsMessageType::SUBSCRIPTIONS_RESPONSE` | Value obtained from FuzzedDataProvider | This also ensures that the plugin is always deterministic for any given input. ## Build This describes steps to build vehicleManager_fuzzer binary. ### Android #### Steps to build Build the fuzzer ``` $ mm -j$(nproc) vehicleManager_fuzzer ``` #### Steps to run Create a directory CORPUS_DIR ``` $ adb shell mkdir /data/local/tmp/CORPUS_DIR ``` ##### Some Additional steps needed to run the vehicleManager_fuzzer successfully on device 1. Push the following libraries from /vendor/lib/ and /vendor/lib64/ folders of your workspace to the device's /vendor/lib/ and /vendor/lib64/ : ``` 1.1 android.hardware.automotive.vehicle@2.0.so 1.2 carwatchdog_aidl_interface-V2-ndk_platform.so ``` 2. Now, reboot the device using command ``` $ adb reboot ``` ##### To run the fuzzer on device ``` $ adb sync data $ adb shell LD_LIBRARY_PATH=/vendor/lib64 /data/fuzz/${TARGET_ARCH}/vehicleManager_fuzzer/vendor/vehicleManager_fuzzer /data/local/tmp/CORPUS_DIR ``` ## References: * http://llvm.org/docs/LibFuzzer.html * https://github.com/google/oss-fuzz