Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 617650 - x11-drivers/nvidia-drivers-304.135: FATAL: modpost: GPL-incompatible module nvidia.ko uses GPL-only symbol 'kmemcheck_mark_initialized'
Summary: x11-drivers/nvidia-drivers-304.135: FATAL: modpost: GPL-incompatible module n...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-06 14:28 UTC by segmentation fault
Modified: 2019-01-16 10:49 UTC (History)
1 user (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 segmentation fault 2017-05-06 14:28:17 UTC
Upon compiling x11-drivers/nvidia-drivers-304.135 I got:

FATAL: modpost: GPL-incompatible module nvidia.ko uses GPL-only symbol 'kmemcheck_mark_initialized'
/usr/src/linux-4.9.25-gentoo/scripts/Makefile.modpost:91: recipe for target '__modpost' failed
make[4]: *** [__modpost] Error 1
/usr/src/linux-4.9.25-gentoo/Makefile:1493: recipe for target 'modules' failed
make[3]: *** [modules] Error 2
Makefile:150: recipe for target 'sub-make' failed
make[2]: *** [sub-make] Error 2
NVIDIA: left KBUILD.
nvidia.ko failed to build!
Makefile:257: recipe for target 'module' failed
make[1]: *** [module] Error 1
makefile:59: recipe for target 'module' failed
make: *** [module] Error 2


Reason
------

Somehow (although I did not need it), I chose 'kmemckeck' in

Kernel hacking --> Memory Debugging --> kmemcheck - trap use of uninitialized memory

which set CONFIG_KMEMCHECK in the kernel configuration. This was seen by nvidia-drivers and triggered the use of a 'symbol' that is reserved for GPL-only modules.

Quote:
    "When a loadable module is inserted, any references it makes to kernel functions and data structures must be linked to the current running kernel. The module loader does not provide access to all kernel symbols, however; only those which have been explicitly exported are available.

    Exports come in two flavors: vanilla (EXPORT_SYMBOL) and GPL-only (EXPORT_SYMBOL_GPL). The former are available to any kernel module, while the latter cannot be used by any modules which do not carry a GPL-compatible license."


Background on EXPORT_SYMBOL_GPL:

On the value of EXPORT_SYMBOL_GPL
https://lwn.net/Articles/154602/

and

Questioning EXPORT_SYMBOL_GPL()
https://lwn.net/Articles/603131/


Solution
--------

From what I understand, you have 3 options:

1) Change

EXPORT_SYMBOL_GPL(kmemcheck_mark_initialized);

to

EXPORT_SYMBOL(kmemcheck_mark_initialized);

in

arch/x86/mm/kmemcheck/shadow.c

2) Disable kmemckeck in 

Kernel hacking --> Memory Debugging

3) Talk to NVIDIA developers and persuade them to use something else.


Now, 1) is not likely to be accepted by kernel developers, 2) is not likely to be accepted by the user
and 3) is not likely to be accepted by NVIDIA developers.

What I really don't understand is: what for? Why deny a module the capability to


/*
 * Fill the shadow memory of the given address such that the memory at that
 * address is marked as being initialized.
 */


if the module is not GPLed? If one wants to really go that far, one can just as well say
"we deny proprietary graphics drivers ALL important kernel functions"! This defies the purpose
of using proprietary modules. I just don't get it.

To quote 'nix' in the second of the above LWN articles:

"the real reason for this marking was probably 'this was horribly hard to get right so it feels wrong if proprietary modules can benefit from our hard work' -- but EXPORT_SYMBOL_GPL isn't meant to be a 'this was a hard bit' marker, is it?"

Note that even an amateur kernel hacker can write a GPLed module that (by construction) will be able to see ALL GPL exported functions - and export them itself without restrictions. This is covered by both GPL and freedom of expression, so - I say it again - I fail to see the reason for all this mess.

To me this is a kernel bug. If you feel otherwise, please leave this here - it might help people with the same problem. Feel free to point 'upstream' (e.g. NVIDIA developers) here and tell them to use their workarounds. Thank you.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2019-01-16 10:49:42 UTC
commit eb22dfef2d7c2ae67f092cbbdd9a0631ca609f56
Author: Jeroen Roovers <jer@gentoo.org>
Date:   Wed Jan 16 10:59:29 2019 +0100

    x11-drivers/nvidia-drivers: Drop unmaintained branches

    Bug: https://bugs.gentoo.org/669588
    Closes: https://bugs.gentoo.org/673392
    Closes: https://bugs.gentoo.org/673490
    Package-Manager: Portage-2.3.56, Repoman-2.3.12
    Signed-off-by: Jeroen Roovers <jer@gentoo.org>