1/* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18package { 19 default_team: "trendy_team_android_kernel", 20} 21 22cc_defaults { 23 name: "liblp_fuzz_defaults", 24 header_libs: [ 25 "libstorage_literals_headers", 26 ], 27 shared_libs: [ 28 "liblp", 29 "libbase", 30 "liblog", 31 ], 32 static_libs: [ 33 "libcutils", 34 ], 35 include_dirs: [ 36 "system/core/fs_mgr/liblp", 37 ], 38 fuzz_config: { 39 cc: [ 40 "android-systems-storage@google.com", 41 ], 42 componentid: 59148, 43 hotlists: ["4593311"], 44 description: "The fuzzers target the APIs of all liblp modules", 45 vector: "local_no_privileges_required", 46 service_privilege: "privileged", 47 users: "multi_user", 48 fuzzed_code_usage: "shipped", 49 }, 50} 51 52cc_fuzz { 53 name: "liblp_builder_fuzzer", 54 srcs: ["liblp_builder_fuzzer.cpp"], 55 defaults: ["liblp_fuzz_defaults"], 56} 57 58cc_fuzz { 59 name: "liblp_super_layout_builder_fuzzer", 60 srcs: ["liblp_super_layout_builder_fuzzer.cpp"], 61 defaults: ["liblp_fuzz_defaults"], 62} 63 64python_binary_host { 65 name: "image_gen_rand", 66 srcs: ["image_gen_rand.py"], 67} 68 69genrule_defaults { 70 name: "test_data_gen_defaults", 71 tools: [ 72 "image_gen_rand", 73 ], 74} 75 76// Fake dtb image. 77genrule { 78 name: "test_dtb", 79 defaults: ["test_data_gen_defaults"], 80 out: ["test_dtb.img"], 81 cmd: "$(location image_gen_rand) --seed dtb --length 1024 > $(out)", 82} 83 84// Fake bootconfig image. 85genrule { 86 name: "test_bootconfig", 87 defaults: ["test_data_gen_defaults"], 88 out: ["test_bootconfig.img"], 89 cmd: "$(location image_gen_rand) --seed bootconfig --length 1024 > $(out)", 90} 91 92// Fake vendor ramdisk with type "none". 93genrule { 94 name: "test_vendor_ramdisk_none", 95 defaults: ["test_data_gen_defaults"], 96 out: ["test_vendor_ramdisk_none.img"], 97 cmd: "$(location image_gen_rand) --seed vendor_ramdisk_none --length 1024 > $(out)", 98} 99 100// Fake vendor ramdisk with type "platform". 101genrule { 102 name: "test_vendor_ramdisk_platform", 103 defaults: ["test_data_gen_defaults"], 104 out: ["test_vendor_ramdisk_platform.img"], 105 cmd: "$(location image_gen_rand) --seed vendor_ramdisk_platform --length 1024 > $(out)", 106} 107 108// Fake replacement ramdisk. 109genrule { 110 name: "test_vendor_ramdisk_replace", 111 defaults: ["test_data_gen_defaults"], 112 out: ["test_vendor_ramdisk_replace.img"], 113 cmd: "$(location image_gen_rand) --seed replace --length 3072 > $(out)", 114} 115 116// Genrules for test vendor boot images. 117fastboot_sign_test_image = "$(location avbtool) add_hash_footer --salt 00 --image $(out) " + 118 "--partition_name vendor_boot --partition_size $$(( 1 * 1024 * 1024 ))" 119 120genrule_defaults { 121 name: "test_vendor_boot_gen_defaults", 122 defaults: ["test_data_gen_defaults"], 123 tools: [ 124 "avbtool", 125 "mkbootimg", 126 ], 127} 128 129genrule { 130 name: "test_vendor_boot_v3", 131 defaults: ["test_vendor_boot_gen_defaults"], 132 out: ["test_vendor_boot_v3.img"], 133 srcs: [ 134 ":test_dtb", 135 ":test_vendor_ramdisk_none", 136 ], 137 cmd: "$(location mkbootimg) --header_version 3 " + 138 "--vendor_ramdisk $(location :test_vendor_ramdisk_none) " + 139 "--dtb $(location :test_dtb) " + 140 "--vendor_boot $(out) && " + 141 fastboot_sign_test_image, 142} 143 144genrule { 145 name: "test_vendor_boot_v4_without_frag", 146 defaults: ["test_vendor_boot_gen_defaults"], 147 out: ["test_vendor_boot_v4_without_frag.img"], 148 srcs: [ 149 ":test_dtb", 150 ":test_vendor_ramdisk_none", 151 ":test_bootconfig", 152 ], 153 cmd: "$(location mkbootimg) --header_version 4 " + 154 "--vendor_ramdisk $(location :test_vendor_ramdisk_none) " + 155 "--dtb $(location :test_dtb) " + 156 "--vendor_bootconfig $(location :test_bootconfig) " + 157 "--vendor_boot $(out) && " + 158 fastboot_sign_test_image, 159} 160 161genrule { 162 name: "test_vendor_boot_v4_with_frag", 163 defaults: ["test_vendor_boot_gen_defaults"], 164 out: ["test_vendor_boot_v4_with_frag.img"], 165 srcs: [ 166 ":test_dtb", 167 ":test_vendor_ramdisk_none", 168 ":test_vendor_ramdisk_platform", 169 ":test_bootconfig", 170 ], 171 cmd: "$(location mkbootimg) --header_version 4 " + 172 "--dtb $(location :test_dtb) " + 173 "--vendor_bootconfig $(location :test_bootconfig) " + 174 "--ramdisk_type none --ramdisk_name none_ramdisk " + 175 "--vendor_ramdisk_fragment $(location :test_vendor_ramdisk_none) " + 176 "--ramdisk_type platform --ramdisk_name platform_ramdisk " + 177 "--vendor_ramdisk_fragment $(location :test_vendor_ramdisk_platform) " + 178 "--vendor_boot $(out) && " + 179 fastboot_sign_test_image, 180} 181 182cc_fuzz { 183 name: "liblp_apis_fuzzer", 184 srcs: [ 185 "liblp_apis_fuzzer.cpp", 186 ":TestPartitionOpener_group", 187 ], 188 defaults: ["liblp_fuzz_defaults"], 189 shared_libs: [ 190 "libsparse", 191 ], 192 data: [ 193 ":test_dtb", 194 ":test_bootconfig", 195 ":test_vendor_ramdisk_none", 196 ":test_vendor_ramdisk_platform", 197 ":test_vendor_ramdisk_replace", 198 ":test_vendor_boot_v3", 199 ":test_vendor_boot_v4_without_frag", 200 ":test_vendor_boot_v4_with_frag", 201 ], 202 cflags: [ 203 "-Wno-unused-parameter", 204 ], 205} 206