Build Android Kernel of Pixel 6 for Fuzzing

less than 1 minute read

Published:

This post records how I build kernel of pixel 6 for fuzzing.

Installing Repo

sudo apt-get update
sudo apt-get install repo

Downloading the Source

mkdir aosp
cd aosp
repo init -u https://android.googlesource.com/platform/manifest -b master
repo sync -c -j16

Downloading vendor

wget https://dl.google.com/dl/android/aosp/google_devices-oriole-sq1d.220205.004-a2628da5.tgz

or

wget https://dl.google.com/dl/android/aosp/google_devices-oriole-7989861-f65f74aa.tgz

Building Android

source build/envsetup.sh
lunch aosp_oriole_hwasan-userdebug
m

Flashing aosp

  • notice: must in the same shell of building aosp for the environment

use customize kernel

cp ../android-kernel/out/android-gs-pixel-5.10/dist/Image.lz4 ./device/google/raviole-kernel/
cp ../android-kernel/out/android-gs-pixel-5.10/dist/*.ko ./device/google/raviole-kernel/
cd out/target/product/oriole
adb reboot bootloader
ANDROID_PRODUCT_OUT=`pwd` fastboot flashall -w

other resource:
https://blog.kyrios.cn/2021-07-android-11-building-on-pixel-3/
https://blog.senyuuri.info/2020/04/16/fuzzing-a-pixel-3a-kernel-with-syzkaller/
https://flash.android.com/welcome

Building Kernels

mkdir android-kernel
cd android-kernel
repo init -u https://android.googlesource.com/kernel/manifest -b android-gs-raviole-5.10-android12-qpr1-d
repo sync -c -j16
build/build.sh

  • enable KCOV in config file android-kernel/private/gs-google/arch/arm64/configs/gki_defconfig
    cd android-kernel
    build/build.sh
    

Unlock Phone

enable oem unlock in develop mode

adb reboot bootloader
fastboot flashing unlock