Commit graph

7 commits

Author SHA1 Message Date
Yi-Yo Chiang
40a8223d34 libfstab_fuzzer: fuzz TransformFstabForDsu() and skip mount logic
These functions contain complex logic and parse user input. It shall be
valuable to fuzz these functions to prevent regression.

Bug: 254832225
Test: Build and run the fuzzer
Change-Id: I21099c3fc1c226f95a0f8f996bb751030e0c59bc
2022-10-21 19:51:25 +08:00
Bob Badour
c9605e6ae1 Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  fastboot/fuzzer/Android.bp
  fs_mgr/fuzz/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Change-Id: I3bb21e1af846d175a345c2a3a632dc47ecdd62de
2022-02-10 11:12:20 -08:00
Yi-Yo Chiang
97f2fdff68 Reland "Add ParseFstabFromString(), remove ReadFstabFromFp()"
ReadFstabFromFp() have two callers right now, ReadFstabFromFile() and
ReadFstabFromDt(). ReadFstabFromFile() opens a FILE* and pass it to
ReadFstabFromFp(), and ReadFstabFromDt() wraps a std::string::c_str()
buffer in a FILE* adaptor with fmemopen().

There's no need for such adaptor, just change ReadFstabFromFp() to
accept std::string and we're good.

Bug: 206740783
Bug: 204056804
Test: atest CtsFsMgrTestCases
Test: m libfstab_fuzzer
Change-Id: I3f56a83ec5baf7b0d97a618a2c2bb6e31b67b5d9
2021-11-17 16:52:17 +00:00
Martin Stjernholm
62291bfd5c Revert "Add ParseFstabFromString(), remove ReadFstabFromFp()"
Revert submission 1890098

Reason for revert: Breaks tests, b/206740783
Reverted Changes:
I71190c735:Add ParseFstabFromString(), remove ReadFstabFromFp...
Ic1dd0eb97:Replace strtok_r() with C++-style android::base::T...

Change-Id: I1ded0217670a9bf3f2485120ee0dddf3e854a6fb
2021-11-17 15:51:01 +00:00
Yi-Yo Chiang
c811d139aa Add ParseFstabFromString(), remove ReadFstabFromFp()
ReadFstabFromFp() have two callers right now, ReadFstabFromFile() and
ReadFstabFromDt(). ReadFstabFromFile() opens a FILE* and pass it to
ReadFstabFromFp(), and ReadFstabFromDt() wraps a std::string::c_str()
buffer in a FILE* adaptor with fmemopen().

There's no need for such adaptor, just change ReadFstabFromFp() to
accept std::string and we're good.

Bug: 204056804
Test: atest CtsFsMgrTestCases
Test: m libfstab_fuzzer
Change-Id: I71190c7356a354aa06d1be3fdc4ca76611b3896d
2021-11-15 14:27:19 +08:00
Yi-Yo Chiang
ed72e37c4a libfstab_fuzzer: Add dictionary to guide the fuzzer
This is probably an overkill, but still, add a collection of
interesting keywords that may appear in a fstab file.

Also add myself to the "CC" list of this fuzz target.

BYPASS_INCLUSIVE_LANGUAGE_REASON="slave" or MS_SLAVE is a mount flag

Bug: 204056804
Test: adb shell /data/fuzz/x86_64/libfstab_fuzzer/libfstab_fuzzer \
  -dict=/data/fuzz/x86_64/libfstab_fuzzer/fstab.dict
Change-Id: Ife55837212a711dcbeed4f00d97da0cb022c7156
2021-10-26 23:03:33 +08:00
Yi-Yo Chiang
b398a0bc73 Add libfstab_fuzzer that fuzzes ReadFstabFile()
Just a modest initial implementation. Uses the fuzz data as the fstab
file content directly.

Bug: 204056804
Test: lunch aosp_cf_x86_64_phone-userdebug
  SANITIZE_TARGET=address m libfstab_fuzzer
  adb sync data
  adb shell /data/fuzz/x86_64/libfstab_fuzzer/libfstab_fuzzer
Change-Id: I7976a6ee124e9b5da59cfa7f4bae9699be3f1474
2021-10-26 14:22:36 +08:00