Skip to content

Commit d649d2c

Browse files
committed
Merge tag 'pstore-v6.0-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull pstore revert from Kees Cook: "A misbehavior with some compression backends in pstore was just discovered due to the recent crypto acomp migration. Since we're so close to release, it seems better to just simply revert it, and we can figure out what's going on without leaving it broken for a release. - Revert crypto acomp migration (Guilherme G. Piccoli)" * tag 'pstore-v6.0-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: Revert "pstore: migrate to crypto acomp interface"
2 parents 89e10b8 + 40158db commit d649d2c

File tree

1 file changed

+12
-51
lines changed

1 file changed

+12
-51
lines changed

fs/pstore/platform.c

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@
2828
#include <linux/crypto.h>
2929
#include <linux/string.h>
3030
#include <linux/timer.h>
31-
#include <linux/scatterlist.h>
3231
#include <linux/slab.h>
3332
#include <linux/uaccess.h>
3433
#include <linux/jiffies.h>
3534
#include <linux/workqueue.h>
3635

37-
#include <crypto/acompress.h>
38-
3936
#include "internal.h"
4037

4138
/*
@@ -93,8 +90,7 @@ module_param(compress, charp, 0444);
9390
MODULE_PARM_DESC(compress, "compression to use");
9491

9592
/* Compression parameters */
96-
static struct crypto_acomp *tfm;
97-
static struct acomp_req *creq;
93+
static struct crypto_comp *tfm;
9894

9995
struct pstore_zbackend {
10096
int (*zbufsize)(size_t size);
@@ -272,21 +268,12 @@ static const struct pstore_zbackend zbackends[] = {
272268
static int pstore_compress(const void *in, void *out,
273269
unsigned int inlen, unsigned int outlen)
274270
{
275-
struct scatterlist src, dst;
276271
int ret;
277272

278273
if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS))
279274
return -EINVAL;
280275

281-
sg_init_table(&src, 1);
282-
sg_set_buf(&src, in, inlen);
283-
284-
sg_init_table(&dst, 1);
285-
sg_set_buf(&dst, out, outlen);
286-
287-
acomp_request_set_params(creq, &src, &dst, inlen, outlen);
288-
289-
ret = crypto_acomp_compress(creq);
276+
ret = crypto_comp_compress(tfm, in, inlen, out, &outlen);
290277
if (ret) {
291278
pr_err("crypto_comp_compress failed, ret = %d!\n", ret);
292279
return ret;
@@ -297,7 +284,7 @@ static int pstore_compress(const void *in, void *out,
297284

298285
static void allocate_buf_for_compression(void)
299286
{
300-
struct crypto_acomp *acomp;
287+
struct crypto_comp *ctx;
301288
int size;
302289
char *buf;
303290

@@ -309,7 +296,7 @@ static void allocate_buf_for_compression(void)
309296
if (!psinfo || tfm)
310297
return;
311298

312-
if (!crypto_has_acomp(zbackend->name, 0, CRYPTO_ALG_ASYNC)) {
299+
if (!crypto_has_comp(zbackend->name, 0, 0)) {
313300
pr_err("Unknown compression: %s\n", zbackend->name);
314301
return;
315302
}
@@ -328,24 +315,16 @@ static void allocate_buf_for_compression(void)
328315
return;
329316
}
330317

331-
acomp = crypto_alloc_acomp(zbackend->name, 0, CRYPTO_ALG_ASYNC);
332-
if (IS_ERR_OR_NULL(acomp)) {
318+
ctx = crypto_alloc_comp(zbackend->name, 0, 0);
319+
if (IS_ERR_OR_NULL(ctx)) {
333320
kfree(buf);
334321
pr_err("crypto_alloc_comp('%s') failed: %ld\n", zbackend->name,
335-
PTR_ERR(acomp));
336-
return;
337-
}
338-
339-
creq = acomp_request_alloc(acomp);
340-
if (!creq) {
341-
crypto_free_acomp(acomp);
342-
kfree(buf);
343-
pr_err("acomp_request_alloc('%s') failed\n", zbackend->name);
322+
PTR_ERR(ctx));
344323
return;
345324
}
346325

347326
/* A non-NULL big_oops_buf indicates compression is available. */
348-
tfm = acomp;
327+
tfm = ctx;
349328
big_oops_buf_sz = size;
350329
big_oops_buf = buf;
351330

@@ -355,8 +334,7 @@ static void allocate_buf_for_compression(void)
355334
static void free_buf_for_compression(void)
356335
{
357336
if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) {
358-
acomp_request_free(creq);
359-
crypto_free_acomp(tfm);
337+
crypto_free_comp(tfm);
360338
tfm = NULL;
361339
}
362340
kfree(big_oops_buf);
@@ -693,8 +671,6 @@ static void decompress_record(struct pstore_record *record)
693671
int ret;
694672
int unzipped_len;
695673
char *unzipped, *workspace;
696-
struct acomp_req *dreq;
697-
struct scatterlist src, dst;
698674

699675
if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !record->compressed)
700676
return;
@@ -718,38 +694,23 @@ static void decompress_record(struct pstore_record *record)
718694
if (!workspace)
719695
return;
720696

721-
dreq = acomp_request_alloc(tfm);
722-
if (!dreq) {
723-
kfree(workspace);
724-
return;
725-
}
726-
727-
sg_init_table(&src, 1);
728-
sg_set_buf(&src, record->buf, record->size);
729-
730-
sg_init_table(&dst, 1);
731-
sg_set_buf(&dst, workspace, unzipped_len);
732-
733-
acomp_request_set_params(dreq, &src, &dst, record->size, unzipped_len);
734-
735697
/* After decompression "unzipped_len" is almost certainly smaller. */
736-
ret = crypto_acomp_decompress(dreq);
698+
ret = crypto_comp_decompress(tfm, record->buf, record->size,
699+
workspace, &unzipped_len);
737700
if (ret) {
738-
pr_err("crypto_acomp_decompress failed, ret = %d!\n", ret);
701+
pr_err("crypto_comp_decompress failed, ret = %d!\n", ret);
739702
kfree(workspace);
740703
return;
741704
}
742705

743706
/* Append ECC notice to decompressed buffer. */
744-
unzipped_len = dreq->dlen;
745707
memcpy(workspace + unzipped_len, record->buf + record->size,
746708
record->ecc_notice_size);
747709

748710
/* Copy decompressed contents into an minimum-sized allocation. */
749711
unzipped = kmemdup(workspace, unzipped_len + record->ecc_notice_size,
750712
GFP_KERNEL);
751713
kfree(workspace);
752-
acomp_request_free(dreq);
753714
if (!unzipped)
754715
return;
755716

0 commit comments

Comments
 (0)