]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Kernel and modules have "set_vnet" linker set, where virtualized
authortrociny <trociny@FreeBSD.org>
Thu, 27 Sep 2012 14:55:15 +0000 (14:55 +0000)
committertrociny <trociny@FreeBSD.org>
Thu, 27 Sep 2012 14:55:15 +0000 (14:55 +0000)
commitd677fb07e182e385be1459f5c49b3c4a8676b360
tree8c2723ade02d11c2edb9a60af5fd2692165d754a
parentcec93f2f0fd32287db02b1dd801bf4b271535e5c
Kernel and modules have "set_vnet" linker set, where virtualized
global variables are placed. When a module is loaded by link_elf
linker its variables from "set_vnet" linker set are copied to the
kernel "set_vnet" ("modspace") and all references to these variables
inside the module are relocated accordingly.

The issue is when a module is loaded that has references to global
variables from another, previously loaded module: these references are
not relocated so an invalid address is used when the module tries to
access the variable. The example is V_layer3_chain, defined in ipfw
module and accessed from ipfw_nat.

The same issue is with DPCPU variables, which use "set_pcpu" linker
set.

Fix this making the link_elf linker on a module load recognize
"external" DPCPU/VNET variables defined in the previously loaded
modules and relocate them accordingly. For this set_pcpu_list and
set_vnet_list are used, where the addresses of modules' "set_pcpu" and
"set_vnet" linker sets are stored.

Note, archs that use link_elf_obj (amd64) were not affected by this
issue.

Reviewed by: jhb, julian, zec (initial version)
MFC after: 1 month
sys/kern/link_elf.c