pstore/platform: build fix when crypto API are disabled
PATCH 1/1 pstore/platform: build fix when crypto API are disabled
From: Matteo Croce <[email protected]>
When building a kernel with CONFIG_PSTORE=y and CONFIG_CRYPTO not set, a build error happens:
ld: fs/pstore/platform.o: in function `pstore_dump':
platform.c:(.text+0x3f9): undefined reference to `crypto_comp_compress'
ld: fs/pstore/platform.o: in function `pstore_get_backend_records':
platform.c:(.text+0x784): undefined reference to `crypto_comp_decompress'
This because some pstore code uses crypto_comp_(de)compress regardless of the CONFIG_CRYPTO status.
Fix it by wrapping the (de)compress usage by IS_ENABLED(CONFIG_PSTORE_COMPRESS)
--- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/pstore/platform.c +2 -2
@@ -436,7 +436,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, dst_size, &dump_size))break ; -if (big_oops_buf) { +if (IS_ENABLED (CONFIG_PSTORE_COMPRESS ) && big_oops_buf) { zipped_len =pstore_compress (dst, psinfo->buf, header_size + dump_size, psinfo->bufsize);
@@ -668,7 +668,7 @@ static void decompress_record(struct pstore_record *record)int unzipped_len;char *unzipped, *workspace; -if (!record->compressed) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESS ) || !record->compressed)return ;/* Only PSTORE_TYPE_DMESG support compression. */
Signature · 1 line
2.26.2
Quoted 5 lines · Matteo Croce
From: Matteo Croce <[email protected]>
When building a kernel with
CONFIG_PSTORE=yandCONFIG_CRYPTOnot set, a build error happens:
Quoted 8 lines
ld:
fs/pstore/platform.o: in function `pstore_dump':
platform.c:(.text+0x3f9): undefined reference to `crypto_comp_compress'
ld:fs/pstore/platform.o: in function `pstore_get_backend_records':
platform.c:(.text+0x784): undefined reference to `crypto_comp_decompress'This because some pstore code uses crypto_comp_(de)compress regardless of the
CONFIG_CRYPTOstatus.
Fix it by wrapping the (de)compress usage byIS_ENABLED(CONFIG_PSTORE_COMPRESS)
I'm surprised this hasn't come up before in a randconfig! But I guess it'd require a very lucky config: picking CONFIG_PSTORE but not CONFIG_CRYPTO _and_ 0 of the many compression options in pstore. :P
But yes, I can reproduce this with:
# CONFIG_CRYPTO is not setCONFIG_PSTORE=y
# CONFIG_PSTORE_DEFLATE_COMPRESS is not set
# CONFIG_PSTORE_LZO_COMPRESS is not set
# CONFIG_PSTORE_LZ4_COMPRESS is not set
# CONFIG_PSTORE_LZ4HC_COMPRESS is not set
# CONFIG_PSTORE_842_COMPRESS is not set
# CONFIG_PSTORE_ZSTD_COMPRESS is not set
Quoted 30 lines
Signed-off-by Matteo Croce <[email protected]>--- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/pstore/platform.c +2
-2@@ -436,7 +436,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, dst_size, &dump_size))break ; -if (big_oops_buf) { +if (IS_ENABLED (CONFIG_PSTORE_COMPRESS ) && big_oops_buf) { zipped_len =pstore_compress (dst, psinfo->buf, header_size + dump_size, psinfo->bufsize);@@ -668,7 +668,7 @@ static void decompress_record(struct pstore_record *record)int unzipped_len;char *unzipped, *workspace; -if (!record->compressed) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESS ) || !record->compressed)return ;/* Only PSTORE_TYPE_DMESG support compression. */ Signature · 1 line
2.26.2
This report also reminds me that I want to stop hard-coding the possible compressors[1].
Regardless, for now, I'd like a slightly different patch, which pokes pstore_compress() instead of doing it inline in pstore_dump():
fs/pstore/platform.c +4 -1
@@ -269,6 +269,9 @@ static int pstore_compress(const void *in, void *out, {int ret; +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION )) +return -EINVAL ; + ret =crypto_comp_compress (tfm, in, inlen, out, &outlen);if (ret) {pr_err ("crypto_comp_compress failed, ret = %d!\n" , ret);
@@ -668,7 +671,7 @@ static void decompress_record(struct pstore_record *record)int unzipped_len;char *unzipped, *workspace; -if (!record->compressed) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION ) || !record->compressed)return ;/* Only PSTORE_TYPE_DMESG support compression. */
Let me know if that works for you (it fixes it on my end).
Thanks!
-Kees
[1] https://lore.kernel.org/lkml/[email protected]/
Signature · 1 line
Kees Cook
Quoted 95 lines · Kees Cook
Quoted 5 lines · Matteo Croce
From: Matteo Croce <[email protected]>
When building a kernel with
CONFIG_PSTORE=yandCONFIG_CRYPTOnot set, a build error happens:Quoted 8 lines
ld:
fs/pstore/platform.o: in function `pstore_dump':
platform.c:(.text+0x3f9): undefined reference to `crypto_comp_compress'
ld:fs/pstore/platform.o: in function `pstore_get_backend_records':
platform.c:(.text+0x784): undefined reference to `crypto_comp_decompress'This because some pstore code uses crypto_comp_(de)compress regardless of the
CONFIG_CRYPTOstatus.
Fix it by wrapping the (de)compress usage byIS_ENABLED(CONFIG_PSTORE_COMPRESS)I'm surprised this hasn't come up before in a randconfig! But I guess it'd require a very lucky config: picking
CONFIG_PSTOREbut notCONFIG_CRYPTO_and_ 0 of the many compression options in pstore. :PBut yes, I can reproduce this with:
#
CONFIG_CRYPTOis not setCONFIG_PSTORE=y
#CONFIG_PSTORE_DEFLATE_COMPRESSis not set
#CONFIG_PSTORE_LZO_COMPRESSis not set
#CONFIG_PSTORE_LZ4_COMPRESSis not set
#CONFIG_PSTORE_LZ4HC_COMPRESSis not set
#CONFIG_PSTORE_842_COMPRESSis not set
#CONFIG_PSTORE_ZSTD_COMPRESSis not setQuoted 29 lines
Signed-off-by Matteo Croce <[email protected]>--- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/pstore/platform.c +2
-3@@ -436,7 +436,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, dst_size, &dump_size))break ; -if (big_oops_buf) { +if (IS_ENABLED (CONFIG_PSTORE_COMPRESS ) && big_oops_buf) { zipped_len =pstore_compress (dst, psinfo->buf, header_size + dump_size, psinfo->bufsize);@@ -668,7 +668,7 @@ static void decompress_record(struct pstore_record *record)int unzipped_len;char *unzipped, *workspace; -if (!record->compressed) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESS ) || !record->compressed)return ;/* Only PSTORE_TYPE_DMESG support compression. */ --Quoted 1 line
2.26.2
This report also reminds me that I want to stop hard-coding the possible compressors[1].
Regardless, for now, I'd like a slightly different patch, which pokes
pstore_compress()instead of doing it inline inpstore_dump():fs/pstore/platform.c +4
-1@@ -269,6 +269,9 @@ static int pstore_compress(const void *in, void *out, {int ret; +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION )) +return -EINVAL ; + ret =crypto_comp_compress (tfm, in, inlen, out, &outlen);if (ret) {pr_err ("crypto_comp_compress failed, ret = %d!\n" , ret);@@ -668,7 +671,7 @@ static void decompress_record(struct pstore_record *record)int unzipped_len;char *unzipped, *workspace; -if (!record->compressed) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION ) || !record->compressed)return ;/* Only PSTORE_TYPE_DMESG support compression. */
Quoted 2 lines
Let me know if that works for you (it fixes it on my end).
Yes, it works for me!
Signature · 1 line
per aspera ad upstream