History

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"

Linus Torvalds committed 4 years ago

Commit d649d2c2 parents 89e10b8 40158db1 file · +12 −51Browse files

Unified · Split

fs/pstore/platform.c+12−51
@@ -28,14 +28,11 @@ · 27 unmodified lines
28#include <linux/crypto.h>28#include <linux/crypto.h>
29#include <linux/string.h>29#include <linux/string.h>
30#include <linux/timer.h>30#include <linux/timer.h>
31#include <linux/scatterlist.h>
32#include <linux/slab.h>31#include <linux/slab.h>
33#include <linux/uaccess.h>32#include <linux/uaccess.h>
34#include <linux/jiffies.h>33#include <linux/jiffies.h>
35#include <linux/workqueue.h>34#include <linux/workqueue.h>
36 35
37#include <crypto/acompress.h>
38
39#include "internal.h"36#include "internal.h"
40 37
41/*38/*
@@ -93,8 +90,7 @@ module_param(compress, charp, 0444); · 51 unmodified lines
93MODULE_PARM_DESC(compress, "compression to use");90MODULE_PARM_DESC(compress, "compression to use");
94 91
95/* Compression parameters */92/* Compression parameters */
96static struct crypto_acomp *tfm;93static struct crypto_comp *tfm;
97static struct acomp_req *creq;
98 94
99struct pstore_zbackend {95struct pstore_zbackend {
100 int (*zbufsize)(size_t size);96 int (*zbufsize)(size_t size);
@@ -272,21 +268,12 @@ static const struct pstore_zbackend zbackends[] = { · 171 unmodified lines
272static int pstore_compress(const void *in, void *out,268static int pstore_compress(const void *in, void *out,
273 unsigned int inlen, unsigned int outlen)269 unsigned int inlen, unsigned int outlen)
274{270{
275 struct scatterlist src, dst;
276 int ret;271 int ret;
277 272
278 if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS))273 if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS))
279 return -EINVAL;274 return -EINVAL;
280 275
281 sg_init_table(&src, 1);276 ret = crypto_comp_compress(tfm, in, inlen, out, &outlen);
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);
290 if (ret) {277 if (ret) {
291 pr_err("crypto_comp_compress failed, ret = %d!\n", ret);278 pr_err("crypto_comp_compress failed, ret = %d!\n", ret);
292 return ret;279 return ret;
@@ -297,7 +284,7 @@ static int pstore_compress(const void *in, void *out, · 4 unmodified lines
297 284
298static void allocate_buf_for_compression(void)285static void allocate_buf_for_compression(void)
299{286{
300 struct crypto_acomp *acomp;287 struct crypto_comp *ctx;
301 int size;288 int size;
302 char *buf;289 char *buf;
303 290
@@ -309,7 +296,7 @@ static void allocate_buf_for_compression(void) · 5 unmodified lines
309 if (!psinfo || tfm)296 if (!psinfo || tfm)
310 return;297 return;
311 298
312 if (!crypto_has_acomp(zbackend->name, 0, CRYPTO_ALG_ASYNC)) {299 if (!crypto_has_comp(zbackend->name, 0, 0)) {
313 pr_err("Unknown compression: %s\n", zbackend->name);300 pr_err("Unknown compression: %s\n", zbackend->name);
314 return;301 return;
315 }302 }
@@ -328,24 +315,16 @@ static void allocate_buf_for_compression(void) · 12 unmodified lines
328 return;315 return;
329 }316 }
330 317
331 acomp = crypto_alloc_acomp(zbackend->name, 0, CRYPTO_ALG_ASYNC);318 ctx = crypto_alloc_comp(zbackend->name, 0, 0);
332 if (IS_ERR_OR_NULL(acomp)) {319 if (IS_ERR_OR_NULL(ctx)) {
333 kfree(buf);320 kfree(buf);
334 pr_err("crypto_alloc_comp('%s') failed: %ld\n", zbackend->name,321 pr_err("crypto_alloc_comp('%s') failed: %ld\n", zbackend->name,
335 PTR_ERR(acomp));322 PTR_ERR(ctx));
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);
344 return;323 return;
345 }324 }
346 325
347 /* A non-NULL big_oops_buf indicates compression is available. */326 /* A non-NULL big_oops_buf indicates compression is available. */
348 tfm = acomp;327 tfm = ctx;
349 big_oops_buf_sz = size;328 big_oops_buf_sz = size;
350 big_oops_buf = buf;329 big_oops_buf = buf;
351 330
@@ -355,8 +334,7 @@ static void allocate_buf_for_compression(void) · 3 unmodified lines
355static void free_buf_for_compression(void)334static void free_buf_for_compression(void)
356{335{
357 if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) {336 if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) {
358 acomp_request_free(creq);337 crypto_free_comp(tfm);
359 crypto_free_acomp(tfm);
360 tfm = NULL;338 tfm = NULL;
361 }339 }
362 kfree(big_oops_buf);340 kfree(big_oops_buf);
@@ -693,8 +671,6 @@ static void decompress_record(struct pstore_record *record) · 330 unmodified lines
693 int ret;671 int ret;
694 int unzipped_len;672 int unzipped_len;
695 char *unzipped, *workspace;673 char *unzipped, *workspace;
696 struct acomp_req *dreq;
697 struct scatterlist src, dst;
698 674
699 if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !record->compressed)675 if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !record->compressed)
700 return;676 return;
@@ -718,30 +694,16 @@ static void decompress_record(struct pstore_record *record) · 17 unmodified lines
718 if (!workspace)694 if (!workspace)
719 return;695 return;
720 696
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
735 /* After decompression "unzipped_len" is almost certainly smaller. */697 /* 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);
737 if (ret) {700 if (ret) {
738 pr_err("crypto_acomp_decompress failed, ret = %d!\n", ret);701 pr_err("crypto_comp_decompress failed, ret = %d!\n", ret);
739 kfree(workspace);702 kfree(workspace);
740 return;703 return;
741 }704 }
742 705
743 /* Append ECC notice to decompressed buffer. */706 /* Append ECC notice to decompressed buffer. */
744 unzipped_len = dreq->dlen;
745 memcpy(workspace + unzipped_len, record->buf + record->size,707 memcpy(workspace + unzipped_len, record->buf + record->size,
746 record->ecc_notice_size);708 record->ecc_notice_size);
747 709
@@ -749,7 +711,6 @@ static void decompress_record(struct pstore_record *record) · 1 unmodified line
749 unzipped = kmemdup(workspace, unzipped_len + record->ecc_notice_size,711 unzipped = kmemdup(workspace, unzipped_len + record->ecc_notice_size,
750 GFP_KERNEL);712 GFP_KERNEL);
751 kfree(workspace);713 kfree(workspace);
752 acomp_request_free(dreq);
753 if (!unzipped)714 if (!unzipped)
754 return;715 return;
755 716