by nerdponx · 9y ago · 0 comments
What's the purpose of including this in the kernel itself? Why couldn't developers just use some kind of "libsiphash" instead?
Hash functions aren't included in the kernel for exposure to userspace, they're included for internal kernel use.
edit: see e.g. this email from Linus: http://www.openwall.com/lists/kernel-hardening/2016/12/13/5
The kernel does allow for loadable modules but the point of some of these hashes is to replace calls to some md5 and sha equivalents inside the kernel itself. As a result, the symbols would need to be defined at compile time (so these functions need to be compiled in).
Header: https://git.kernel.org/cgit/linux/kernel/git/davem/net-next....
Source: https://git.kernel.org/cgit/linux/kernel/git/davem/net-next....
Technically I think it could be built as a dynamically loadable kernel module and shipped separately from the kernel image under /lib/modules. This does not make sense if the functionality is always needed, in which case it should be statically compiled in.
In any case there is no benefit of developping separately considering that the module must call functionality from the kernel (at least for the entropy part) so the code is tightly bound to the kernel (and to specific versions of the kernel at that).
The functionality could also live in userland, and the kernel could start a process, which links the libsiphash shared library. The process could then communicate with the kernel by other means, reducing dependencies. And of course that would be too slow.
Edit: although I think the developers could include it as a statically linked library at compile time even if it's used in the kernel?