module: fix out-by-one error in kallsyms
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 25 Oct 2012 00:19:25 +0000 (10:49 +1030)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 16 Nov 2012 16:47:01 +0000 (16:47 +0000)
commit1d60939abd811d472171dfe714c3d25804fc2693
treed689986e688b7c88dc1249457da098d7477e213b
parentee5e9ba331c346da00557849bbe75ba7e2be3333
module: fix out-by-one error in kallsyms

commit 59ef28b1f14899b10d6b2682c7057ca00a9a3f47 upstream.

Masaki found and patched a kallsyms issue: the last symbol in a
module's symtab wasn't transferred.  This is because we manually copy
the zero'th entry (which is always empty) then copy the rest in a loop
starting at 1, though from src[0].  His fix was minimal, I prefer to
rewrite the loops in more standard form.

There are two loops: one to get the size, and one to copy.  Make these
identical: always count entry 0 and any defined symbol in an allocated
non-init section.

This bug exists since the following commit was introduced.
   module: reduce symbol table for loaded modules (v2)
   commit: 4a4962263f07d14660849ec134ee42b63e95ea9a

LKML: http://lkml.org/lkml/2012/10/24/27
Reported-by: Masaki Kimura <masaki.kimura.kz@hitachi.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
[bwh: Backported to 3.2: we're still using a bitmap to compress the string
 table]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
kernel/module.c