linux/net/dccp
Neil Horman de4ef86cfc dccp: fix dccp rmmod when kernel configured to use slub
Hey all-
	I was tinkering with dccp recently and noticed that I BUG halted the
kernel when I rmmod-ed the dccp module.  The bug halt occured because the page
that I passed to kfree failed the PageCompound and PageSlab test in the slub
implementation of kfree.  I tracked the problem down to the following set of
events:

1) dccp, unlike all other uses of kmem_cache_create, allocates a string
dynamically when registering a slab cache.  This allocated string is freed when
the cache is destroyed.

2) Normally, (1) is not an issue, but when Slub is in use, it is possible that
caches are 'merged'.  This process causes multiple caches of simmilar
configuration to use the same cache data structure.  When this happens, the new
name of the cache is effectively dropped.

3) (2) results in kmem_cache_name returning an ambigous value (i.e.
ccid_kmem_cache_destroy, which uses this fuction to retrieve the name pointer
for freeing), is no longer guaranteed that the string it assigned is what is
returned.

4) If such merge event occurs, ccid_kmem_cache_destroy frees the wrong pointer,
which trips over the BUG in the slub implementation of kfree (since its likely
not a slab allocation, but rather a pointer into the static string table
section.

So, what to do about this.  At first blush this is pretty clearly a leak in the
information that slub owns, and as such a slub bug.  Unfortunately, theres no
really good way to fix it, without exposing slub specific implementation details
to the generic slab interface.  Also, even if we could fix this in slub cleanly,
I think the RCU free option would force us to do lots of string duplication, not
only in slub, but in every slab allocator.  As such, I'd like to propose this
solution.  Basically, I just move the storage for the kmem cache name to the
ccid_operations structure.  In so doing, we don't have to do the kstrdup or
kfree when we allocate/free the various caches for dccp, and so we avoid the
problem, by storing names with static memory, rather than heap, the way all
other calls to kmem_cache_create do.

I've tested this out myself here, and it solves the problem quite well.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-01-19 01:59:01 -08:00
..
ccids dccp ccid-3: Remove CCID naming redundancy 2/2 2009-10-07 13:51:24 -07:00
ackvec.c dccp: Set per-connection CCIDs via socket options 2008-11-23 16:02:31 -08:00
ackvec.h dccp: Minimise header option overhead in setting the MPS 2009-03-02 03:07:23 -08:00
ccid.c dccp: fix dccp rmmod when kernel configured to use slub 2010-01-19 01:59:01 -08:00
ccid.h dccp: fix dccp rmmod when kernel configured to use slub 2010-01-19 01:59:01 -08:00
dccp.h net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
diag.c dccp_diag: LISTEN sockets don't have CCIDs 2008-12-17 16:08:01 -08:00
feat.c net: mark read-only arrays as const 2009-08-05 10:42:58 -07:00
feat.h dccp: Debugging functions for feature negotiation 2009-01-21 14:34:05 -08:00
input.c dccp: Integrate the TFRC library with DCCP 2009-01-04 21:45:33 -08:00
ipv4.c tcp: Fix a connect() race with timewait sockets 2009-12-08 20:17:51 -08:00
ipv6.c tcp: Fix a connect() race with timewait sockets 2009-12-08 20:17:51 -08:00
ipv6.h Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
Kconfig dccp: Lockless integration of CCID congestion-control plugins 2009-01-04 21:42:53 -08:00
Makefile dccp: Integrate the TFRC library with DCCP 2009-01-04 21:45:33 -08:00
minisocks.c TCPCT part 1a: add request_values parameter for sending SYNACK 2009-12-02 22:07:23 -08:00
options.c dccp: Debugging functions for feature negotiation 2009-01-21 14:34:05 -08:00
output.c inet: rename some inet_sock fields 2009-10-18 18:52:53 -07:00
probe.c dccp_probe: Fix module load dependencies between dccp and dccp_probe 2010-01-15 01:40:55 -08:00
proto.c inet: rename some inet_sock fields 2009-10-18 18:52:53 -07:00
sysctl.c sysctl net: Remove unused binary sysctl code 2009-11-12 02:05:06 -08:00
timer.c net: Fix for dst_negative_advice 2009-10-20 18:55:46 -07:00