Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 589436 - linux-mod.eclass: external kernel module packages fail when CONFIG_STACK_VALIDATION is set but elfutils are not installed
Summary: linux-mod.eclass: external kernel module packages fail when CONFIG_STACK_VALI...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
: 646590 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-07-23 09:08 UTC by Marcin Kowalski
Modified: 2021-08-24 02:25 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Kowalski 2016-07-23 09:08:23 UTC
Like the title says, external kernel modules like nvidia-drivers or virtualbox-modules fail with cryptic error messages when this package is not installed while the option is set. This doesn't break the kernel build itself, so a careless user might not notice it.

Steps to reproduce
- build kernel with CONFIG_STACK_VALIDATION=y, without elfutils installed
- try building external kernel modules against it
- observe failure
- install elfutils, rebuild kernel
- try again
- observe success

IMHO it might be worth making a config check and bail out if elfutils are not provided. 

When building the kernel a warning can be seen 

"Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev or elfutils-libelf-devel"

although it doesn't break the kernel, and can be easily missed on -j4 or higher parallel builds.



The kernel error msg also mentions libelf package might be a satisfactory dependency, but i have not tested this.
Comment 1 Marcel Sondaar 2017-05-06 18:26:13 UTC
I have observed with x11-drivers/nvidia-drivers that it doesn't build either way when CONFIG_STACK_VALIDATION is set.

Without libelf it tries to invoke the linker before any source files have been compiled:
  x86_64-pc-linux-gnu-ld: cannot find /var/tmp/portage/x11-drivers/nvidia-drivers-378.13/work/kernel/nvidia/nv-frontend.o: No such file or directory
  x86_64-pc-linux-gnu-ld: cannot find /var/tmp/portage/x11-drivers/nvidia-drivers-378.13/work/kernel/nvidia/nv-instance.o: No such file or directory
  x86_64-pc-linux-gnu-ld: cannot find /var/tmp/portage/x11-drivers/nvidia-drivers-378.13/work/kernel/nvidia/nv.o: No such file or directory
  (...)

With libelf it raised a different compile error:
  error reading elf file /var/tmp/portage/x11-drivers/nvidia-drivers-378.13/work/kernel/nvidia/nv-frontend.o

I solved it on my system by disabling the offending kernel config and rerunning 
  make modules_prepare

In addition, trying to formulate reproduction steps have lead to the conclusion that the kernel Makefile probably caches more than it should. For the first error this could be enough:
  uninstall libelf if necessary
  enable CONFIG_STACK_VALIDATION
  in /usr/src/linux, run make oldconfig
  in /usr/src/linux/tools/objtool, run make clean
  in /usr/src/linux, run make modules_prepare
  emerge nvidia-drivers

the second error then follows:
  emerge libelf
  in /usr/src/linux, run make modules_prepare
  emerge nvidia-drivers

I haven't tried installing elfutils as the kernel did not hint at that, and the two packages block each other.

kernel version used is 4.9.6-gentoo-r1
nvidia-drivers version used is 378.13



I'd recommend that ebuilds throw an error if libelf is not installed in conjunction with CONFIG_STACK_VALIDATION when it would be expected (suggestion to test for the presence of objtool in the kernel in addition to libelf.so). 

NVidia drivers not compiling regardless of this might well be a separate issue but at least the error messages can now appear in google and save the next person from a day's worth of frustration ;)
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2020-06-17 05:10:20 UTC
*** Bug 646590 has been marked as a duplicate of this bug. ***
Comment 3 Mike Pagano gentoo-dev 2021-08-23 23:10:00 UTC
This seems more an external driver issue and not an kernel issue.
ionen, you have thoughts concerning nvidia here?
Comment 4 Ionen Wolkens gentoo-dev 2021-08-24 02:13:32 UTC
Believe this was already handled by:
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f9b2693b32b7c7c7c561ae417cbd757624184327

So I don't think there's anything that needs to be done here, virtual/libelf (and so elfutils) should always be on the system if using kernel sources.

(In reply to Marcel Sondaar from comment #1)
> I have observed with x11-drivers/nvidia-drivers that it doesn't build either
> way when CONFIG_STACK_VALIDATION is set.
I can't reproduce this, if anything CONFIG_STACK_VALIDATION is a default option of `make defconfig` (as mentioned in above commit) and nvidia-drivers been building with this for a long time.

I think this is just obsolete