pstore: Remove worst-case compression size logic
authorArd Biesheuvel <ardb@kernel.org>
Wed, 12 Jul 2023 16:23:31 +0000 (18:23 +0200)
committerKees Cook <keescook@chromium.org>
Mon, 17 Jul 2023 23:08:58 +0000 (16:08 -0700)
commit1756ddea6916669125933a8625120c84b57f6559
tree506c7dd337aea802b33033ea2a0594f475d80f77
parentfdf0eaf11452d72945af31804e2a1048ee1b574c
pstore: Remove worst-case compression size logic

The worst case compression size used by pstore gives an upper bound for
how much the data might inadvertently *grow* due to encapsulation
overhead if the input is not compressible at all.

Given that pstore records have individual 'compressed' flags, we can
simply store the uncompressed data if compressing it would end up using
more space, making the worst case identical to the uncompressed case.

This means we can just drop all the elaborate logic that reasons about
upper bounds for each individual compression algorithm, and just store
the uncompressed data directly if compression fails for any reason.

Co-developed-by: Kees Cook <keescook@chromium.org>
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-2-ardb@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
fs/pstore/platform.c