Skip to content

Commit 58eb5b6

Browse files
arndbkees
authored andcommitted
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: cb3bee0 ("pstore: Use crypto compress API") Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent cb3bee0 commit 58eb5b6

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

fs/pstore/Kconfig

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
config PSTORE
22
tristate "Persistent store support"
3+
select CRYPTO if PSTORE_COMPRESS
34
default n
45
help
56
This option enables generic access to platform level
@@ -13,7 +14,7 @@ config PSTORE
1314
say N.
1415

1516
config PSTORE_DEFLATE_COMPRESS
16-
bool "DEFLATE (ZLIB) compression"
17+
tristate "DEFLATE (ZLIB) compression"
1718
default y
1819
depends on PSTORE
1920
select CRYPTO_DEFLATE
@@ -22,21 +23,21 @@ config PSTORE_DEFLATE_COMPRESS
2223
algorithm support.
2324

2425
config PSTORE_LZO_COMPRESS
25-
bool "LZO compression"
26+
tristate "LZO compression"
2627
depends on PSTORE
2728
select CRYPTO_LZO
2829
help
2930
This option enables LZO compression algorithm support.
3031

3132
config PSTORE_LZ4_COMPRESS
32-
bool "LZ4 compression"
33+
tristate "LZ4 compression"
3334
depends on PSTORE
3435
select CRYPTO_LZ4
3536
help
3637
This option enables LZ4 compression algorithm support.
3738

3839
config PSTORE_LZ4HC_COMPRESS
39-
bool "LZ4HC compression"
40+
tristate "LZ4HC compression"
4041
depends on PSTORE
4142
select CRYPTO_LZ4HC
4243
help
@@ -70,19 +71,19 @@ choice
7071
The default compression algorithm is deflate.
7172

7273
config PSTORE_DEFLATE_COMPRESS_DEFAULT
73-
bool "deflate" if PSTORE_DEFLATE_COMPRESS=y
74+
bool "deflate" if PSTORE_DEFLATE_COMPRESS
7475

7576
config PSTORE_LZO_COMPRESS_DEFAULT
76-
bool "lzo" if PSTORE_LZO_COMPRESS=y
77+
bool "lzo" if PSTORE_LZO_COMPRESS
7778

7879
config PSTORE_LZ4_COMPRESS_DEFAULT
79-
bool "lz4" if PSTORE_LZ4_COMPRESS=y
80+
bool "lz4" if PSTORE_LZ4_COMPRESS
8081

8182
config PSTORE_LZ4HC_COMPRESS_DEFAULT
82-
bool "lz4hc" if PSTORE_LZ4HC_COMPRESS=y
83+
bool "lz4hc" if PSTORE_LZ4HC_COMPRESS
8384

8485
config PSTORE_842_COMPRESS_DEFAULT
85-
bool "842" if PSTORE_842_COMPRESS=y
86+
bool "842" if PSTORE_842_COMPRESS
8687

8788
endchoice
8889

fs/pstore/platform.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#include <linux/console.h>
2929
#include <linux/module.h>
3030
#include <linux/pstore.h>
31-
#ifdef CONFIG_PSTORE_LZO_COMPRESS
31+
#if IS_ENABLED(CONFIG_PSTORE_LZO_COMPRESS)
3232
#include <linux/lzo.h>
3333
#endif
34-
#if defined(CONFIG_PSTORE_LZ4_COMPRESS) || defined(CONFIG_PSTORE_LZ4HC_COMPRESS)
34+
#if IS_ENABLED(CONFIG_PSTORE_LZ4_COMPRESS) || IS_ENABLED(CONFIG_PSTORE_LZ4HC_COMPRESS)
3535
#include <linux/lz4.h>
3636
#endif
3737
#include <linux/crypto.h>
@@ -142,7 +142,7 @@ bool pstore_cannot_block_path(enum kmsg_dump_reason reason)
142142
}
143143
EXPORT_SYMBOL_GPL(pstore_cannot_block_path);
144144

145-
#ifdef CONFIG_PSTORE_DEFLATE_COMPRESS
145+
#if IS_ENABLED(CONFIG_PSTORE_DEFLATE_COMPRESS)
146146
static int zbufsize_deflate(size_t size)
147147
{
148148
size_t cmpr;
@@ -171,21 +171,21 @@ static int zbufsize_deflate(size_t size)
171171
}
172172
#endif
173173

174-
#ifdef CONFIG_PSTORE_LZO_COMPRESS
174+
#if IS_ENABLED(CONFIG_PSTORE_LZO_COMPRESS)
175175
static int zbufsize_lzo(size_t size)
176176
{
177177
return lzo1x_worst_compress(size);
178178
}
179179
#endif
180180

181-
#if defined(CONFIG_PSTORE_LZ4_COMPRESS) || defined(CONFIG_PSTORE_LZ4HC_COMPRESS)
181+
#if IS_ENABLED(CONFIG_PSTORE_LZ4_COMPRESS) || IS_ENABLED(CONFIG_PSTORE_LZ4HC_COMPRESS)
182182
static int zbufsize_lz4(size_t size)
183183
{
184184
return LZ4_compressBound(size);
185185
}
186186
#endif
187187

188-
#ifdef CONFIG_PSTORE_842_COMPRESS
188+
#if IS_ENABLED(CONFIG_PSTORE_842_COMPRESS)
189189
static int zbufsize_842(size_t size)
190190
{
191191
return size;
@@ -195,31 +195,31 @@ static int zbufsize_842(size_t size)
195195
static const struct pstore_zbackend *zbackend __ro_after_init;
196196

197197
static const struct pstore_zbackend zbackends[] = {
198-
#ifdef CONFIG_PSTORE_DEFLATE_COMPRESS
198+
#if IS_ENABLED(CONFIG_PSTORE_DEFLATE_COMPRESS)
199199
{
200200
.zbufsize = zbufsize_deflate,
201201
.name = "deflate",
202202
},
203203
#endif
204-
#ifdef CONFIG_PSTORE_LZO_COMPRESS
204+
#if IS_ENABLED(CONFIG_PSTORE_LZO_COMPRESS)
205205
{
206206
.zbufsize = zbufsize_lzo,
207207
.name = "lzo",
208208
},
209209
#endif
210-
#ifdef CONFIG_PSTORE_LZ4_COMPRESS
210+
#if IS_ENABLED(CONFIG_PSTORE_LZ4_COMPRESS)
211211
{
212212
.zbufsize = zbufsize_lz4,
213213
.name = "lz4",
214214
},
215215
#endif
216-
#ifdef CONFIG_PSTORE_LZ4HC_COMPRESS
216+
#if IS_ENABLED(CONFIG_PSTORE_LZ4HC_COMPRESS)
217217
{
218218
.zbufsize = zbufsize_lz4,
219219
.name = "lz4hc",
220220
},
221221
#endif
222-
#ifdef CONFIG_PSTORE_842_COMPRESS
222+
#if IS_ENABLED(CONFIG_PSTORE_842_COMPRESS)
223223
{
224224
.zbufsize = zbufsize_842,
225225
.name = "842",

0 commit comments

Comments
 (0)