Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/78271?usp=email )
Change subject: lib/jpeg: Replace decoder with Wuffs' implementation ......................................................................
lib/jpeg: Replace decoder with Wuffs' implementation
To quote its repo[0]: Wuffs is a memory-safe programming language (and a standard library written in that language) for Wrangling Untrusted File Formats Safely. Wrangling includes parsing, decoding and encoding.
It compiles its library, written in its own language, to a C/C++ source file that can then be used independently without needing support for the language. That library is now imported to src/vendorcode/wuffs/.
This change modifies our linters to ignore that directory because it's supposed to contain the wuffs compiler's result verbatim.
Nigel Tao provided an initial wrapper around wuffs' jpeg decoder that implements our JPEG API. I further changed it a bit regarding data placement, dropped stuff from our API that wasn't ever used, or isn't used anymore, and generally made it fit coreboot a bit better. Features are Nigel's, bugs are mine.
This commit also adapts our jpeg fuzz test to work with the modified API. After limiting it to deal only with approximately screen sized inputs, it fuzzed for 25 hours CPU time without a single hang or crash. This is a notable improvement over running the test with our old decoder which crashes within a minute.
Finally, I tried the new parser with a pretty-much-random JPEG file I got from the internet, and it just showed it (once the resolution matched), which is also a notable improvement over the old decoder which is very particular about the subset of JPEG it supports.
In terms of code size, a QEmu build's ramstage increases from 128060 bytes decompressed (64121 bytes after LZMA) to 172304 bytes decompressed (82734 bytes after LZMA).
[0] https://github.com/google/wuffs
Change-Id: If8fa7da69da1ad412f27c2c5e882393c7739bc82 Signed-off-by: Patrick Georgi patrick@coreboot.org Based-on-work-by: Nigel Tao nigeltao@golang.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/78271 Reviewed-by: Paul Menzel paulepanter@mailbox.org Reviewed-by: Martin L Roth gaumless@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/lib/bootsplash.c M src/lib/jpeg.c M src/lib/jpeg.h A src/vendorcode/wuffs/wuffs-v0.4.c M util/fuzz-tests/jpeg-test.c M util/lint/lint-007-checkpatch M util/lint/lint-stable-004-style-labels 7 files changed, 64,316 insertions(+), 1,013 deletions(-)
Approvals: build bot (Jenkins): Verified Martin L Roth: Looks good to me, approved Paul Menzel: Looks good to me, but someone else must approve