Linux Kernel Architecture

(Jacob Rumans) #1

Chapter7:Modules


kernel/module.c
set_license(mod, get_modinfo(sechdrs, infoindex, "license"));

set_licensechecks whether the license used is GPL-compatible (by comparing its name with the string
in section 7.3.3):

kernel/module.c
static void set_license(struct module *mod, const char *license)
{
if (!license)
license = "unspecified";

if (!license_is_gpl_compatible(license)) {
if (!(tainted & TAINT_PROPRIETARY_MODULE))
printk(KERN_WARNING "%s: module license ’%s’ taints "
"kernel.\n", mod->name, license);
add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
}
}

If the license found is not GPL-compatible, theTAINT_PROPRIETARY_MODULEflag is set in thetainted
global variable viaadd_taint_module, which also taints the module via thetaintsfield instruct
module.license_is_gpl_compatibledetermines which licenses are considered to be GPL-compatible at
the moment:

kernel/module.c
static inline int license_is_gpl_compatible(const char *license)
{
return (strcmp(license, "GPL") == 0
|| strcmp(license, "GPL v2") == 0
|| strcmp(license, "GPL and additional rights") == 0
|| strcmp(license, "Dual BSD/GPL") == 0
|| strcmp(license, "Dual MIT/GPL") == 0
|| strcmp(license, "Dual MPL/GPL") == 0);
}

In an additional step, the kernel is also tainted if the modulendiswrapperordriverwrapperis loaded
into the kernel. Although these modules would comply with the kernel by their own license, their pur-
pose is to load binary data into the kernel (Windows drivers for wireless networking cards in the case of
ndiswrapper). This is incompatible with the kernel’s license and must thus require tainting.

Resolving References and Relocation


The next step is to continue with processing of the module symbols. This task is delegated to the
simplify_symbolsauxiliary function that iterates through all symbols in the symbol table^17 :

kernel/module.c
static int simplify_symbols(Elf_Shdr *sechdrs,
unsigned int symindex,
const char *strtab,
unsigned int versindex,

(^17) The number of symbols is determined by dividing the size of the symbol table by the size of an entry.

Free download pdf