pstore: Replace crypto API compression with zlib_deflate library calls
authorArd Biesheuvel <ardb@kernel.org>
Wed, 12 Jul 2023 16:23:32 +0000 (18:23 +0200)
committerKees Cook <keescook@chromium.org>
Mon, 17 Jul 2023 23:08:58 +0000 (16:08 -0700)
commit438b805003a07606f9a9f222a7ddb7dcdb87aeaa
tree3d97d8b40ffb332643b5023f1bc7b4388598a17f
parent1756ddea6916669125933a8625120c84b57f6559
pstore: Replace crypto API compression with zlib_deflate library calls

Pstore supports compression using a variety of algorithms exposed by the
crypto API. This uses the deprecated comp (as opposed to scomp/acomp)
API, and so we should stop using that, and either move to the new API,
or switch to a different approach entirely.

Given that we only compress ASCII text in pstore, and considering that
this happens when the system is likely to be in an unstable state, the
flexibility that the complex crypto API provides does not outweigh its
impact on the risk that we might encounter additional problems when
trying to commit the kernel log contents to the pstore backend.

So let's switch [back] to the zlib deflate library API, and remove all
the complexity that really has no place in a low-level diagnostic
facility. Note that, while more modern compression algorithms have been
added to the kernel in recent years, the code size of zlib deflate is
substantially smaller than, e.g., zstd, while its performance in terms
of compression ratio is comparable for ASCII text, and speed is deemed
irrelevant in this context.

Note that this means that compressed pstore records may no longer be
accessible after a kernel upgrade, but this has never been part of the
contract. (The choice of compression algorithm is not stored in the
pstore records either)

Tested-by: "Guilherme G. Piccoli" <gpiccoli@igalia.com> # Steam Deck
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20230712162332.2670437-3-ardb@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
fs/pstore/Kconfig
fs/pstore/platform.c