Re: [PATCH v7 2/7] lib: add zstd support to decompress

From: Nick Terrell
Date: Fri Jul 17 2020 - 12:31:04 EST




> On Jul 14, 2020, at 5:42 PM, Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote:
>
> On Wed, Jul 08, 2020 at 11:50:19AM -0700, Nick Terrell wrote:
>> From: Nick Terrell <terrelln@xxxxxx>
>>
>> * Add unzstd() and the zstd decompress interface.
>> * Add zstd support to decompress_method().
>>
>> The decompress_method() and unzstd() functions are used to decompress
>> the initramfs and the initrd. The __decompress() function is used in
>> the preboot environment to decompress a zstd compressed kernel.
>>
>> The zstd decompression function allows the input and output buffers to
>> overlap because that is used by x86 kernel decompression.
>>
>> Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
>> Tested-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
>> Signed-off-by: Nick Terrell <terrelln@xxxxxx>
>> + *
>> + * __DISABLE_EXPORTS stops zstd and xxhash from declaring themselves
>> + * as modules by disabling the EXPORT_SYMBOL macro.
>> + */
>
> Hi Nick, this doesn't actually work, because misc.c includes export.h
> via
> "misc.h" -> <linux/linkage.h> -> <linux/export.h>
> and EXPORT_SYMBOL is already defined before __DISABLE_EXPORTS is defined
> here.
>
> Adding -D__EXPORT_SYMBOLS to KBUILD_CFLAGS in arch/x86/boot/compressed/Makefile
> fixes that, and then you don't have to define it here.
>
> Also, __DISABLE_EXPORTS does not currently inhibit MODULE_INFO, so a
> .modinfo section gets emitted into misc.o. I *think* this is harmless
> and it will get discarded when building compressed/vmlinux, but thought
> I'd point it out.

Thanks for pointing that out! Iâm surprised that the zstd compressed kernels built and ran
successfully, I vaguely remember that failing in the past. I will put up a fix shortly.

-Nick