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: IN_PROGRESS
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2024-05-28 10:19 UTC by Wolfram Schlich
Modified: 2024-12-12 04:50 UTC (History)
5 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
patch commenting out -gt 1 case (genkernel-4.3.16.patch,606 bytes, patch)
2024-11-25 16:22 UTC, Wolfram Schlich
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.
Comment 5 Wolfram Schlich 2024-11-23 18:36:37 UTC
great, stabilizing genkernel 4.3.16 finally brought this stupid bug to a broader audience without being fixed.
Comment 6 Ben Kohler gentoo-dev 2024-11-25 16:04:09 UTC
(In reply to Wolfram Schlich from comment #5)
> great, stabilizing genkernel 4.3.16 finally brought this stupid bug to a
> broader audience without being fixed.

Please attach a patch and I'll get it out ASAP
Comment 7 Wolfram Schlich 2024-11-25 16:22:26 UTC
Created attachment 911896 [details, diff]
patch commenting out -gt 1 case

Here you go.

It's essentially the same as the patch already attached to this bug since 25 Jun 2024 which just removed the lines instead of commenting them out.
Comment 8 Ben Kohler gentoo-dev 2024-11-25 16:26:31 UTC
Thanks, you did not comment on the previous patch so I wasn't sure if that was a suitable fix for you.
Comment 9 Larry the Git Cow gentoo-dev 2024-11-25 17:31:23 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=21da5b2fe83a113d2ea29919fb472ac29f7057e5

commit 21da5b2fe83a113d2ea29919fb472ac29f7057e5
Author:     Ben Kohler <bkohler@gentoo.org>
AuthorDate: 2024-11-25 17:04:24 +0000
Commit:     Ben Kohler <bkohler@gentoo.org>
CommitDate: 2024-11-25 17:31:08 +0000

    sys-kernel/genkernel: revbump for several fixes
    
    Fixes globbing bug, adds musl patches, and fixes lvm2 build for
    non-systemd users.
    
    Bug: https://bugs.gentoo.org/944499
    Bug: https://bugs.gentoo.org/932907
    Bug: https://bugs.gentoo.org/934773
    Signed-off-by: Ben Kohler <bkohler@gentoo.org>

 sys-kernel/genkernel/Manifest                      |   1 +
 .../genkernel-4.3.16-globbing-workaround.patch     |  19 ++
 .../genkernel/files/genkernel-4.3.16-musl.patch    | 297 +++++++++++++++++++++
 .../files/genkernel-4.3.16-posix-shell.patch       |  38 +++
 .../lvm2-2.03.20-dm_lvm_rules_no_systemd.patch     |  11 +
 sys-kernel/genkernel/genkernel-4.3.16-r1.ebuild    | 291 ++++++++++++++++++++
 sys-kernel/genkernel/genkernel-9999.ebuild         |  13 +-
 7 files changed, 668 insertions(+), 2 deletions(-)