Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
My kernel config snippets don't seem to apply
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Sun Jun 15, 2025 11:54 am    Post subject: My kernel config snippets don't seem to apply Reply with quote

Hey everyone!

I was trying to install AppArmor on my Gentoo install, and I have created a kernel config snippet with the required change in /etc/kernel/config.d. The snippet sets CONFIG_SECURITY_APPARMOR=y and CONFIG_LSM="landlock,yama,apparmor,bpf".

I followed pietinger's advice here, changing the current config through the menu and generating a diff to make sure my snippet has everything it needs, and it does seem to be the only required change. CONFIG_SECURITY_APPARMOR isn't even required since it's already on "y", I'm just putting it there in case a future version of the kernel deactivates it. The savedconfig USE FLAG is not set either. I have sys-kernel/gentoo-kernel installed on my system and not the bin version. Yet, my snippet doesn't seem to be merged. It doesn't seem to appear in the build log at all, and both my .config and my config.gz show the old values. Is there another requirement I missed in order to use config snippets?
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Sun Jun 15, 2025 3:00 pm    Post subject: Reply with quote

Does you current running kernel match the one you compiled?
Code:
uname -rv
... will help to see which kernel is being used.
Normally if you use GRUB as your bootloader/manager the /boot/grub/grb.cfg should be updated automatically.

So in short: ensure you really are running the updated kernel.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2390

PostPosted: Sun Jun 15, 2025 3:15 pm    Post subject: Reply with quote

Can we see the full build.log, the path to the snippet, and the full contents of the snippet?
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Mon Jun 16, 2025 7:09 pm    Post subject: Reply with quote

Zucca wrote:
Does you current running kernel match the one you compiled?
Code:
uname -rv
... will help to see which kernel is being used.
Normally if you use GRUB as your bootloader/manager the /boot/grub/grb.cfg should be updated automatically.

So in short: ensure you really are running the updated kernel.

Hello Zucca,

"uname -rv" does return 6.12.31, which is the one I rebuilt, and I made sure I was loading the new one in the UEFI panel, but I'm not seeing any change in the config files, unfortunately. I'm also using an EFI stub rather than GRUB.
sam_ wrote:
Can we see the full build.log, the path to the snippet, and the full contents of the snippet?

Hello, sam_,
The path to the snippet is "/etc/kernel/config.d/lsm.config". The content of lsm.config is:
Code:

CONFIG_SECURITY_APPARMOR=y
CONFIG_LSM="landlock,yama,apparmor,bpf"

And here's my build log.


Last edited by ermor on Thu Jun 19, 2025 11:48 am; edited 1 time in total
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 2075
Location: Germany

PostPosted: Tue Jun 17, 2025 6:38 am    Post subject: Reply with quote

ermor wrote:
And here's part of my build log, unfortunately it's way too large and it won't let me post everything.

You can use something like this to provide the complete output of commands or even just files: https://wiki.gentoo.org/wiki/Wgetpaste
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Tue Jun 17, 2025 6:41 pm    Post subject: Reply with quote

Banana wrote:
ermor wrote:
And here's part of my build log, unfortunately it's way too large and it won't let me post everything.

You can use something like this to provide the complete output of commands or even just files: https://wiki.gentoo.org/wiki/Wgetpaste

Thanks a lot for the tip, Banana! Here's the log, then.
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Sun Jun 22, 2025 6:47 pm    Post subject: Reply with quote

Looking into it some more, it seems I have both
Code:
sys-kernel/gentoo-sources
and
Code:
sys-kernel/gentoo-kernel
in my world. I'm not sure it has anything to do with it, as far as I understand gentoo-sources is ignored with the distribution kernel enabled, but I wonder if this could be a reason. Unfortunately, I'm out of ideas, I don't know enough about the kernel to understand what's wrong with my snippets or configuration.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Mon Jun 23, 2025 6:11 pm    Post subject: Reply with quote

Hm.
It could matter.

What do following commands output in your system:
Code:
qlop -vI gentoo-kernel
qlop -vI gentoo-sources
?
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Mon Jun 23, 2025 7:45 pm    Post subject: Reply with quote

Zucca wrote:
Hm.
It could matter.

What do following commands output in your system:
Code:
qlop -vI gentoo-kernel
qlop -vI gentoo-sources
?

Hello, Zucca!

qlop complains about
Code:
I
(upper-case i) being an invalid option, so I tried
Code:
qlop -vl
instead (lower-case L).

Curiously, both commands don't output anything. I checked in my logs and I still have the logs for both source and kernel in my build and elog folders, though.

EDIT: In addition, I ran another diff between both config files, just to be sure, and there was another change, from
Code:
CONFIG_CC_VERSION_TEXT="x86_64-pc-linux-gnu-gcc (Gentoo Hardened 14.3.0 p8) 14.3.0"
to
Code:
CONFIG_CC_VERSION_TEXT="gcc (Gentoo Hardened 14.3.0 p8) 14.3.0"
I though it was just for reference and didn't really pay attention to it, but then again, it's not working so I might be wrong about that.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Mon Jun 23, 2025 8:47 pm    Post subject: Reply with quote

ermor wrote:
qlop complains
Oh. Sorry. I meant qlist, instead of qlop. Apologies.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Mon Jun 23, 2025 10:07 pm    Post subject: Reply with quote

Zucca wrote:
ermor wrote:
qlop complains
Oh. Sorry. I meant qlist, instead of qlop. Apologies.

No problem, thanks for helping. ^^
Code:
qlist -vI gentoo-kernel
=> sys-kernel/gentoo-kernel-6.12.31
qlist -vI gentoo-sources
=> sys-kernel/gentoo-sources-6.12.31
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Tue Jun 24, 2025 8:36 am    Post subject: Reply with quote

Ok.
What's inside your /boot?
Code:
ls /boot


The log you gave, indeed, indicates that your custom config doesn't get applied.

Let's do a sanity check:
Code:
zfgrep CONFIG_LSM /proc/config.gz
... what does that command output.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Wed Jun 25, 2025 9:32 pm    Post subject: Reply with quote

Zucca wrote:
Ok.
What's inside your /boot?
Code:
ls /boot

Just a grub directory from back when I had it installed.
Zucca wrote:

The log you gave, indeed, indicates that your custom config doesn't get applied.

Let's do a sanity check:
Code:
zfgrep CONFIG_LSM /proc/config.gz
... what does that command output.

Code:
CONFIG_LSM_MMAP_MIN_ADDR=65535
CONFIG_LSM="landlock,yama,bpf"
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Thu Jun 26, 2025 11:33 am    Post subject: Reply with quote

ermor wrote:
Zucca wrote:
Ok.
What's inside your /boot?
Code:
ls /boot

Just a grub directory from back when I had it installed.
Does it contain kernel images (normally containing a string "vmlinuz")? If not, then have you set up some another location for compiled kernel images?
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Thu Jun 26, 2025 11:55 am    Post subject: Reply with quote

Zucca wrote:
ermor wrote:
Zucca wrote:
Ok.
What's inside your /boot?
Code:
ls /boot

Just a grub directory from back when I had it installed.
Does it contain kernel images (normally containing a string "vmlinuz")? If not, then have you set up some another location for compiled kernel images?

It doesn't. It's an UKI EFI boot stub, so as far as I understand, that would be the appropriate .efi file in my EFI partition ("gentoo-6.12.31-gentoo-dist-hardened.efi"), even though it doesn't have vmlinuz in its name.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Thu Jun 26, 2025 4:21 pm    Post subject: Reply with quote

ermor wrote:
It doesn't. It's an UKI EFI boot stub, so as far as I understand, that would be the appropriate .efi file in my EFI partition ("gentoo-6.12.31-gentoo-dist-hardened.efi"), even though it doesn't have vmlinuz in its name.
Ok. This part seems fine then.

You seem to have all correctly set, but for some reason the gentoo-kernel ebuild does not pull in and merge your config snippets.

Let's see the permissions on your config.d -directory:
Code:
ls -lhFa /etc/kernel/config.d

Some ebuild phases are not run by root, but as portage user. man 5 ebuild did not tell me which ones (I know I've read that information from somewhere...).
I have world readable content on my config.d -directory. Let's see if ours match.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Thu Jun 26, 2025 7:18 pm    Post subject: Reply with quote

Zucca wrote:

Let's see the permissions on your config.d -directory:
Code:
ls -lhFa /etc/kernel/config.d

Some ebuild phases are not run by root, but as portage user. man 5 ebuild did not tell me which ones (I know I've read that information from somewhere...).
I have world readable content on my config.d -directory. Let's see if ours match.

That might be the reason, actually. I've set my umask so that permissions are given to root only for files created by root.
Code:
drwx------ 2 root root  24 Jun 25 20:27 ./
drwxr-xr-x 6 root root  74 Jun  3 21:45 ../
-rw------- 1 root root 131 Jun 25 20:27 lsm.config

I could make it world-readable. I can't test it right now, though, since it takes the entire day to build the kernel, but I'll get back to you in a few days with the results.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Thu Jun 26, 2025 7:36 pm    Post subject: Reply with quote

ermor wrote:
Code:
drwx------ 2 root root  24 Jun 25 20:27 ./
drwxr-xr-x 6 root root  74 Jun  3 21:45 ../
-rw------- 1 root root 131 Jun 25 20:27 lsm.config

I could make it world-readable. I can't test it right now, though, since it takes the entire day to build the kernel, but I'll get back to you in a few days with the results.
Also your /etc/kernel/config.d directory is accessible by root only.
Check the access rights of the parent directories too. EDIT: Those should be ok, since permissions for ../ seem correct.
Also you can abort the kernel build process quite early on. There should be messages on the build.log about applying your custom config snippets.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Thu Jun 26, 2025 8:13 pm    Post subject: Reply with quote

Zucca wrote:
ermor wrote:
Code:
drwx------ 2 root root  24 Jun 25 20:27 ./
drwxr-xr-x 6 root root  74 Jun  3 21:45 ../
-rw------- 1 root root 131 Jun 25 20:27 lsm.config

I could make it world-readable. I can't test it right now, though, since it takes the entire day to build the kernel, but I'll get back to you in a few days with the results.
Also your /etc/kernel/config.d directory is accessible by root only.
Check the access rights of the parent directories too. EDIT: Those should be ok, since permissions for ../ seem correct.
Also you can abort the kernel build process quite early on. There should be messages on the build.log about applying your custom config snippets.

It works! Thanks a lot! ^^
Turns out, you do need the file to be world-readable, and to give both r and x permissions to all users on config.d (or maybe just to the portage user, I suppose). I tried giving only read permissions on config.d at first, but the build process fails when trying to merge the file if you don't give execute permissions too:
Code:
Merging /etc/kernel/config.d/lsm.config
The merge file '/etc/kernel/config.d/lsm.config' does not exist. Exit.

This permission thing seems pretty important to know, especially since the build log doesn't actually tell you why it ignores snippets. Think I should add something about it on the config snippets page?


Last edited by ermor on Thu Jun 26, 2025 8:52 pm; edited 3 times in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Thu Jun 26, 2025 8:35 pm    Post subject: Reply with quote

ermor wrote:
and to give both r and x permissions to everyone on config.d. I tried giving only read permissions on config.d at first, but the build process fails when trying to merge the file if you don't give execute permissions too :
Code:
Merging /etc/kernel/config.d/lsm.config
The merge file '/etc/kernel/config.d/lsm.config' does not exist. Exit.

This permission thing seems pretty important to know, especially since the build log doesn't actually tell you why it ignores snippets. Think I should add something about it on the config snippets page?
That's strange... I have -rw-r--r-- 1 root root on all files inside my config.d. The directory itself has the executable bit for world set (drwxr-xr-x 2 root root).

Although I'm running mostly 6.6 -series kernels here.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Thu Jun 26, 2025 8:50 pm    Post subject: Reply with quote

Zucca wrote:
ermor wrote:
and to give both r and x permissions to everyone on config.d. I tried giving only read permissions on config.d at first, but the build process fails when trying to merge the file if you don't give execute permissions too :
Code:
Merging /etc/kernel/config.d/lsm.config
The merge file '/etc/kernel/config.d/lsm.config' does not exist. Exit.

This permission thing seems pretty important to know, especially since the build log doesn't actually tell you why it ignores snippets. Think I should add something about it on the config snippets page?
That's strange... I have -rw-r--r-- 1 root root on all files inside my config.d. The directory itself has the executable bit for world set (drwxr-xr-x 2 root root).

Although I'm running mostly 6.6 -series kernels here.

That seems to match my current settings. I've got all r permissions on my actual config file, and all r and x permissions on the config directory. By "everyone on config.d", I meant "all users", sorry if it was a bit confusing.

I might be dreaming it, but I vaguely remember that I had to create the config directory myself, which might explain why it had less permissions than the usual default.
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5829
Location: Bavaria

PostPosted: Thu Jun 26, 2025 9:15 pm    Post subject: Reply with quote

ermor wrote:
[....] Think I should add something about it on the config snippets page?

Yes, please do ... that helps everyone; unfortunately you can't edit this page https://wiki.gentoo.org/wiki/Project:Distribution_Kernel because it's a protected project page; but you can describe the problem in the corresponding discussion page: https://wiki.gentoo.org/wiki/Project_Talk:Distribution_Kernel

... and maybe put a link to this thread next to your description. I am sure that our developers will respond quickly.

@Zucca: Great found the cause (followed the thread too; but left it to you and @Sam because I didn't had a good idea either).
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 4158
Location: Rasi, Finland

PostPosted: Thu Jun 26, 2025 9:47 pm    Post subject: Reply with quote

ermor wrote:
It works! Thanks a lot! ^^
You're most welcome. ;)
We, both, learned.

I think there's a reason to raise a bug against the ebuild if there's nothing in the build.log indicating a failure to to access the config.d directory, aka. "permission denied".

And yes, like Pietinger mentioned, I think the required permissions for config.d should be at least "side noted" on the wiki page.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23584

PostPosted: Thu Jun 26, 2025 11:53 pm    Post subject: Reply with quote

eclass/kernel-build.eclass uses a shell glob to find the files to pull in. From some cursory testing, the shell does not return failure when permissions prevent a glob:
Code:
$ ls /root
ls: cannot open directory '/root': Permission denied
$ (a=( /root/*.config ); echo $?)
0
The glob necessarily fails since, per the previous line, my user does not have permission to list /root. Despite that failure, $? is still 0. The eclass could still try to detect restrictive permissions and warn, such as by
Code:
$ if ! [[ -r /root ]]; then echo 'Cannot read /root'; fi
Cannot read /root
Back to top
View user's profile Send private message
ermor
n00b
n00b


Joined: 05 Jan 2025
Posts: 27

PostPosted: Mon Jun 30, 2025 7:20 pm    Post subject: Reply with quote

pietinger wrote:
ermor wrote:
[....] Think I should add something about it on the config snippets page?

Yes, please do ... that helps everyone; unfortunately you can't edit this page https://wiki.gentoo.org/wiki/Project:Distribution_Kernel because it's a protected project page; but you can describe the problem in the corresponding discussion page: https://wiki.gentoo.org/wiki/Project_Talk:Distribution_Kernel

... and maybe put a link to this thread next to your description. I am sure that our developers will respond quickly.

@Zucca: Great found the cause (followed the thread too; but left it to you and @Sam because I didn't had a good idea either).

I started a discussion and submitted a bug report.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum