4 ms·
I have never come anywhere near developing a kernel in my life. What's the purpose of including this in the kernel itself? Why couldn't developers just use som
by nerdponx 10y ago
I have never come anywhere near developing a kernel in my life.
What's the purpose of including this in the kernel itself? Why couldn't developers just use some kind of "libsiphash" instead?
- kspaans 10y agoGenerally speaking, the kernel community doesn't like to add external dependencies. And then including it in the kernel tree gives some advantages: architecture-specific speed hacks can be applied, kernel-specific utilities can be used in the implementation.
- foota 10y agoMaybe it's used in the kernel? 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?
- deleted 10y ago[deleted]
- zx2c4 10y agoThis implementation is optimized for kernel usage and follows kernel idioms. If you're curious, here's the source: Header: https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/tree/include/linux/siphash.h https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.... Source: https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/tree/lib/siphash.c https://git.kernel.org/cgit/linux/kernel/git/davem/net-next....
- jstimpfle 10y agoMy guess (not a kernel developer): 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.
- ajdlinux 10y agoI haven't been actively watching SipHash but I do subscribe to the linux-hardening list and have seen a little bit of the discussion - my understanding is there are a bunch of potential applications in the kernel in areas that already use other hash functions, such as TCP sequence numbers, which are security sensitive, where SipHash could be faster and/or more secure. 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 http://www.openwall.com/lists/kernel-hardening/2016/12/13/5
- mfukar 10y agoThe primary users of siphash, as seen in lkml, are ipv[4|6] syncookies (/net/ipv4/syncookies.c), and TCP sequence numbers (/net/core/secure_seq.c).
- zx2c4 10y agoHopefully not "primary" for long. These are just the first uses I saw to immediately convert to siphash with the least amount of controversy to actually get siphash in the kernel. Now that these have landed, other developers can gradually start using it in more and more places. Who knows what the "primary" use will be after 4.11.
- alfalfasprout 10y agoWhen in the kernel you don't really have access to most of the standard library so there's no real guarantee that "libsiphash" wouldn't need symbols defined elsewhere. 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).
- geofft 10y agoThis isn't intended for userspace developers to use - they should use a libsiphash. This is intended for use where the kernel needs cryptographically strong hash tables and such, which happens about as often in the kernel as in any userspace program of comparable complexity and functionality.