Re: [PATCH 1/9] crypto: add zbufsize() interface
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2018-08-07 09:45:45
Also in:
lkml
On Thu, Aug 02, 2018 at 02:51:10PM -0700, Kees Cook wrote:
quoted hunk ↗ jump to hunk
When pstore was refactored to use the crypto compress API in: commit cb3bee0369bc ("pstore: Use crypto compress API") nearly all the pstore-specific compression routines were replaced with the existing crypto compression API. One case remained: calculating the "worst case" compression sizes ahead of time so it could have a buffer preallocated for doing compression (which was called "zbufsize"). To make pstore fully algorithm-agnostic, the compression API needs to grow this functionality. This adds the interface to support querying the "worst case" estimate, with a new "zbufsize" routine that each compressor can implement. The per-compressor implementations come in later commits. Signed-off-by: Kees Cook <redacted> --- crypto/compress.c | 9 +++++++++ include/crypto/internal/scompress.h | 11 +++++++++++ include/linux/crypto.h | 12 ++++++++++++ 3 files changed, 32 insertions(+)diff --git a/crypto/compress.c b/crypto/compress.c index f2d522924a07..29a80bb3b9d3 100644 --- a/crypto/compress.c +++ b/crypto/compress.c@@ -33,12 +33,21 @@ static int crypto_decompress(struct crypto_tfm *tfm, dlen); } +static int crypto_zbufsize(struct crypto_tfm *tfm, + unsigned int slen, unsigned int *dlen) +{ + if (!tfm->__crt_alg->cra_compress.coa_zbufsize) + return -ENOTSUPP; + return tfm->__crt_alg->cra_compress.coa_zbufsize(tfm, slen, dlen); +}
Please don't add new features to the old compress interface. Any new improvements should be added to scomp/acomp only. Users who need new features should be converted. Thanks, -- Email: Herbert Xu [off-list ref] Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt