Commit 58eb5b67 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Kees Cook

pstore: fix crypto dependencies

The new crypto API use causes some problems with Kconfig dependencies,
including this link error:

fs/pstore/platform.o: In function `pstore_register':
platform.c:(.text+0x248): undefined reference to `crypto_has_alg'
platform.c:(.text+0x2a0): undefined reference to `crypto_alloc_base'
fs/pstore/platform.o: In function `pstore_unregister':
platform.c:(.text+0x498): undefined reference to `crypto_destroy_tfm'
crypto/lz4hc.o: In function `lz4hc_sdecompress':
lz4hc.c:(.text+0x1a): undefined reference to `LZ4_decompress_safe'
crypto/lz4hc.o: In function `lz4hc_decompress_crypto':
lz4hc.c:(.text+0x5a): undefined reference to `LZ4_decompress_safe'
crypto/lz4hc.o: In function `lz4hc_scompress':
lz4hc.c:(.text+0xaa): undefined reference to `LZ4_compress_HC'
crypto/lz4hc.o: In function `lz4hc_mod_init':
lz4hc.c:(.init.text+0xf): undefined reference to `crypto_register_alg'
lz4hc.c:(.init.text+0x1f): undefined reference to `crypto_register_scomp'
lz4hc.c:(.init.text+0x2f): undefined reference to `crypto_unregister_alg'

The problem is that with CONFIG_CRYPTO=m, we must not 'select CRYPTO_LZ4'
from a bool symbol, or call crypto API functions from a built-in
module.

This turns the sub-options into 'tristate' ones so the dependencies
are honored, and makes the pstore itself select the crypto core
if necessary.

Fixes: cb3bee03 ("pstore: Use crypto compress API")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent cb3bee03
config PSTORE config PSTORE
tristate "Persistent store support" tristate "Persistent store support"
select CRYPTO if PSTORE_COMPRESS
default n default n
help help
This option enables generic access to platform level This option enables generic access to platform level
...@@ -13,7 +14,7 @@ config PSTORE ...@@ -13,7 +14,7 @@ config PSTORE
say N. say N.
config PSTORE_DEFLATE_COMPRESS config PSTORE_DEFLATE_COMPRESS
bool "DEFLATE (ZLIB) compression" tristate "DEFLATE (ZLIB) compression"
default y default y
depends on PSTORE depends on PSTORE
select CRYPTO_DEFLATE select CRYPTO_DEFLATE
...@@ -22,21 +23,21 @@ config PSTORE_DEFLATE_COMPRESS ...@@ -22,21 +23,21 @@ config PSTORE_DEFLATE_COMPRESS
algorithm support. algorithm support.
config PSTORE_LZO_COMPRESS config PSTORE_LZO_COMPRESS
bool "LZO compression" tristate "LZO compression"
depends on PSTORE depends on PSTORE
select CRYPTO_LZO select CRYPTO_LZO
help help
This option enables LZO compression algorithm support. This option enables LZO compression algorithm support.
config PSTORE_LZ4_COMPRESS config PSTORE_LZ4_COMPRESS
bool "LZ4 compression" tristate "LZ4 compression"
depends on PSTORE depends on PSTORE
select CRYPTO_LZ4 select CRYPTO_LZ4
help help
This option enables LZ4 compression algorithm support. This option enables LZ4 compression algorithm support.
config PSTORE_LZ4HC_COMPRESS config PSTORE_LZ4HC_COMPRESS
bool "LZ4HC compression" tristate "LZ4HC compression"
depends on PSTORE depends on PSTORE
select CRYPTO_LZ4HC select CRYPTO_LZ4HC
help help
...@@ -70,19 +71,19 @@ choice ...@@ -70,19 +71,19 @@ choice
The default compression algorithm is deflate. The default compression algorithm is deflate.
config PSTORE_DEFLATE_COMPRESS_DEFAULT config PSTORE_DEFLATE_COMPRESS_DEFAULT
bool "deflate" if PSTORE_DEFLATE_COMPRESS=y bool "deflate" if PSTORE_DEFLATE_COMPRESS
config PSTORE_LZO_COMPRESS_DEFAULT config PSTORE_LZO_COMPRESS_DEFAULT
bool "lzo" if PSTORE_LZO_COMPRESS=y bool "lzo" if PSTORE_LZO_COMPRESS
config PSTORE_LZ4_COMPRESS_DEFAULT config PSTORE_LZ4_COMPRESS_DEFAULT
bool "lz4" if PSTORE_LZ4_COMPRESS=y bool "lz4" if PSTORE_LZ4_COMPRESS
config PSTORE_LZ4HC_COMPRESS_DEFAULT config PSTORE_LZ4HC_COMPRESS_DEFAULT
bool "lz4hc" if PSTORE_LZ4HC_COMPRESS=y bool "lz4hc" if PSTORE_LZ4HC_COMPRESS
config PSTORE_842_COMPRESS_DEFAULT config PSTORE_842_COMPRESS_DEFAULT
bool "842" if PSTORE_842_COMPRESS=y bool "842" if PSTORE_842_COMPRESS
endchoice endchoice
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
#include <linux/console.h> #include <linux/console.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pstore.h> #include <linux/pstore.h>
#ifdef CONFIG_PSTORE_LZO_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_LZO_COMPRESS)
#include <linux/lzo.h> #include <linux/lzo.h>
#endif #endif
#if defined(CONFIG_PSTORE_LZ4_COMPRESS) || defined(CONFIG_PSTORE_LZ4HC_COMPRESS) #if IS_ENABLED(CONFIG_PSTORE_LZ4_COMPRESS) || IS_ENABLED(CONFIG_PSTORE_LZ4HC_COMPRESS)
#include <linux/lz4.h> #include <linux/lz4.h>
#endif #endif
#include <linux/crypto.h> #include <linux/crypto.h>
...@@ -142,7 +142,7 @@ bool pstore_cannot_block_path(enum kmsg_dump_reason reason) ...@@ -142,7 +142,7 @@ bool pstore_cannot_block_path(enum kmsg_dump_reason reason)
} }
EXPORT_SYMBOL_GPL(pstore_cannot_block_path); EXPORT_SYMBOL_GPL(pstore_cannot_block_path);
#ifdef CONFIG_PSTORE_DEFLATE_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_DEFLATE_COMPRESS)
static int zbufsize_deflate(size_t size) static int zbufsize_deflate(size_t size)
{ {
size_t cmpr; size_t cmpr;
...@@ -171,21 +171,21 @@ static int zbufsize_deflate(size_t size) ...@@ -171,21 +171,21 @@ static int zbufsize_deflate(size_t size)
} }
#endif #endif
#ifdef CONFIG_PSTORE_LZO_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_LZO_COMPRESS)
static int zbufsize_lzo(size_t size) static int zbufsize_lzo(size_t size)
{ {
return lzo1x_worst_compress(size); return lzo1x_worst_compress(size);
} }
#endif #endif
#if defined(CONFIG_PSTORE_LZ4_COMPRESS) || defined(CONFIG_PSTORE_LZ4HC_COMPRESS) #if IS_ENABLED(CONFIG_PSTORE_LZ4_COMPRESS) || IS_ENABLED(CONFIG_PSTORE_LZ4HC_COMPRESS)
static int zbufsize_lz4(size_t size) static int zbufsize_lz4(size_t size)
{ {
return LZ4_compressBound(size); return LZ4_compressBound(size);
} }
#endif #endif
#ifdef CONFIG_PSTORE_842_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_842_COMPRESS)
static int zbufsize_842(size_t size) static int zbufsize_842(size_t size)
{ {
return size; return size;
...@@ -195,31 +195,31 @@ static int zbufsize_842(size_t size) ...@@ -195,31 +195,31 @@ static int zbufsize_842(size_t size)
static const struct pstore_zbackend *zbackend __ro_after_init; static const struct pstore_zbackend *zbackend __ro_after_init;
static const struct pstore_zbackend zbackends[] = { static const struct pstore_zbackend zbackends[] = {
#ifdef CONFIG_PSTORE_DEFLATE_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_DEFLATE_COMPRESS)
{ {
.zbufsize = zbufsize_deflate, .zbufsize = zbufsize_deflate,
.name = "deflate", .name = "deflate",
}, },
#endif #endif
#ifdef CONFIG_PSTORE_LZO_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_LZO_COMPRESS)
{ {
.zbufsize = zbufsize_lzo, .zbufsize = zbufsize_lzo,
.name = "lzo", .name = "lzo",
}, },
#endif #endif
#ifdef CONFIG_PSTORE_LZ4_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_LZ4_COMPRESS)
{ {
.zbufsize = zbufsize_lz4, .zbufsize = zbufsize_lz4,
.name = "lz4", .name = "lz4",
}, },
#endif #endif
#ifdef CONFIG_PSTORE_LZ4HC_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_LZ4HC_COMPRESS)
{ {
.zbufsize = zbufsize_lz4, .zbufsize = zbufsize_lz4,
.name = "lz4hc", .name = "lz4hc",
}, },
#endif #endif
#ifdef CONFIG_PSTORE_842_COMPRESS #if IS_ENABLED(CONFIG_PSTORE_842_COMPRESS)
{ {
.zbufsize = zbufsize_842, .zbufsize = zbufsize_842,
.name = "842", .name = "842",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment