]> git.ipfire.org Git - thirdparty/kmod.git/commit
Fix unaligned memory access in hash function
authorAmbroz Bizjak <ambrop7@gmail.com>
Fri, 3 Feb 2012 20:15:01 +0000 (18:15 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Fri, 3 Feb 2012 20:15:01 +0000 (18:15 -0200)
commita2c7d3e8b058a2013aa8da5986d1d11fa13d6fd7
tree79b938007e4ce14d49c0ee5895a9ff4fde57438c
parentc90fc61b6c0afe40d23758f071188a54ecdf5e93
Fix unaligned memory access in hash function

Use a function to properly get an unsigned short from memory that is
possibly unaligned.

Note that it implicitly fixes a small bug in the hash function that
was introduced when modifying the eina code: the line "hash ^= key[2]
<< 18;" is supposed to be accessing the 3rd byte of the remainder of
the input, but when 'it' was introduced, 'key' ('data' in eina code)
was no longer incremented, so this ended up accessing the 3rd byte of
the input from the beginning. This is fixed by iterating over 'key',
like the eina code does.

Before this patch depmod was failing on ARMv5 and possibly others that
don't have unaligned access. They do not calculate correctly the
dependencies as shown below:

[root@alarm ~]# modinfo bridge
filename: /lib/modules/2.6.39.4/kernel/net/bridge/bridge.ko
version: 2.3
license: GPL
srcversion: 6B583530AE2B39C7E2317BF
depends: stp,llc
vermagic: 2.6.39.4 preempt mod_unload ARMv5
[root@alarm ~]# depmod
[root@alarm ~]# cat /lib/modules/2.6.39.4/modules.dep |grep bridge
kernel/net/bridge/bridge.ko:
[root@alarm ~]#

See how modinfo properly lists the dependencies, but modules.dep which
depmod generates does not contain them. As a result, most kernel
modules fail to load because their dependencies are not loaded by
modprobe.
libkmod/libkmod-hash.c