Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 932907 - sys-kernel/genkernel-4.3.15 breaks including regulatory.db due to introduced globbing mechanism
Summary: sys-kernel/genkernel-4.3.15 breaks including regulatory.db due to introduced ...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-28 10:19 UTC by Wolfram Schlich
Modified: 2024-06-26 06:02 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
remove -gt 1 case (0001-remove-gt1-case.patch,680 bytes, patch)
2024-06-26 06:02 UTC, Justin Keogh
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfram Schlich 2024-05-28 10:19:55 UTC
genkernel 4.3.15 introduced the following globbing mechanism for firmware files to be included:

--8<-- snip --8<--
myfw_f=( $(compgen -G "${FIRMWARE_DIR}/${myfw}*") )

if [ ${#myfw_f[@]} -gt 1 ]
then
        gen_die "excessive number of firmwares!"
fi
--8<-- snap --8<--

This effectively breaks including 'regulatory.db' because the file 'regulatory.db.p7s' exists as well, matching the globbing check.

Why on earth is globbing with '*' appended to the firmware files specified being applied?!

Related commit: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=cc7d5e1e32a88dc2a4f144ce6ac9a92a2d679b05
Comment 1 Dmitriy Baranov 2024-05-28 13:33:08 UTC
Because the modinfo generates firmware list without compression extension. For example:

# modinfo -F firmware amdgpu
...
amdgpu/navi12_rlc.bin
amdgpu/navi12_mec2.bin
amdgpu/navi12_mec.bin
amdgpu/navi12_me.bin
amdgpu/navi12_pfp.bin
amdgpu/navi12_ce.bin
...

# ls -1 /lib/firmware/amdgpu/navi12_rlc.bin*
/lib/firmware/amdgpu/navi12_rlc.bin.xz

Looks like we should just get rid "-gt 1" case to reduce the severity level.
Comment 2 Wolfram Schlich 2024-05-28 20:45:28 UTC
(In reply to Dmitriy Baranov from comment #1)
> Because the modinfo generates firmware list without compression extension.
> [...] 

Then it still doesn't make sense to glob with just '*' at the end :-)

According to the CONFIG_MODULE_COMPRESS_* options I found, the only supported compression algorithms are gzip, xz and zstd, so the extensions to look for are limited accordingly.

> Looks like we should just get rid "-gt 1" case to reduce the severity level.

Best would be to check the config options with kconfig_get_opt and add a fixed extension to the file accordingly:

CONFIG_MODULE_COMPRESS_NONE: no extension
CONFIG_MODULE_COMPRESS_GZIP: extension '.gz'
CONFIG_MODULE_COMPRESS_XZ: extension '.xz'
CONFIG_MODULE_COMPRESS_ZSTD: extension '.zst'

(see 'grep CONFIG_MODULE_COMPRESS_ /usr/src/linux/scripts/Makefile.modinst')

Should be easy, right? :)
Comment 3 Dmitriy Baranov 2024-05-29 19:13:46 UTC
(In reply to Wolfram Schlich from comment #2)
> Then it still doesn't make sense to glob with just '*' at the end :-)
> 
> According to the CONFIG_MODULE_COMPRESS_* options I found, the only
> supported compression algorithms are gzip, xz and zstd, so the extensions to
> look for are limited accordingly.

I was aware of CONFIG_MODULE_COMPRESS_* before I made these commits. I consciously chose to use "'*' at the end."

> Should be easy, right? :)

If you dig deeper, a number of difficulties become apparent:
- It is necessary to take into account not only the firmwares but also the modules
- Not all firmware files are packed. ('regulatory.db' is not packed for me)
- Kernel modules can have different extensions (modules from packages outside the kernel)

However, to get rid of '*', you can try to copy files with all possible extensions (including those without). Although, as a temporary solution, I suggest simply removing the "-gt 1" case.

PR is welcome.
Comment 4 Justin Keogh 2024-06-26 06:02:34 UTC
Created attachment 896429 [details, diff]
remove -gt 1 case

Workaround (as suggested, remove the '-gt -1' test) for others hitting this issue.