FROM ubuntu:24.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ ca-certificates git gcc libc6-dev libasan8 && \ rm -rf /var/lib/apt/lists/* WORKDIR /src ARG PIN=ece349ade2973e220f524ce59e59711cc919263f # Clone the real upstream tree and pin it. Fail hard unless HEAD == PIN. RUN git clone https://github.com/u-boot/u-boot.git ub && \ cd ub && \ git checkout --detach ${PIN} && \ HEAD_SHA="$(git rev-parse HEAD)" && \ echo "HEAD=${HEAD_SHA} PIN=${PIN}" && \ [ "${HEAD_SHA}" = "${PIN}" ] || { echo "PIN MISMATCH"; exit 1; } # Extract the REAL types/constants and the REAL functions verbatim from the # pinned tree. No hand-copied code: awk lifts exact line ranges. # include/android_image.h : constants + struct andr_vnd_boot_img_hdr # + struct andr_image_data # boot/image-android.c : checksum/is_trailer_present/add_trailer, # android_vendor_boot_image_v3_v4_parse_hdr, # is_android_vendor_boot_image_header RUN cd /src/ub && \ { awk 'NR>=23 && NR<=36' include/android_image.h; echo; \ awk 'NR>=55 && NR<=78' include/android_image.h; echo; \ awk 'NR>=332 && NR<=361' include/android_image.h; } > /src/gen_defs.h && \ { awk 'NR>=21 && NR<=58' boot/image-android.c; echo; \ awk 'NR>=133 && NR<=180' boot/image-android.c; echo; \ awk 'NR>=452 && NR<=455' boot/image-android.c; } > /src/gen_impl.c && \ echo "===== gen_defs.h =====" && cat /src/gen_defs.h && \ echo "===== gen_impl.c =====" && cat /src/gen_impl.c COPY driver.c /src/driver.c RUN cd /src && \ PIN_SHA="$(cd ub && git rev-parse HEAD)" && \ gcc -std=gnu11 -g -O0 -fno-omit-frame-pointer -fsanitize=address \ -DGITPIN="\"${PIN_SHA}\"" -I/src driver.c -o /src/poc ENV ASAN_OPTIONS=detect_leaks=0:abort_on_error=0:allocator_may_return_null=1 CMD ["/src/poc"]