android_kernel_samsung_msm8226/lib
Jason A. Donenfeld 051e59e292 siphash: add cryptographically secure PRF
commit 2c956a60778cbb6a27e0c7a8a52a91378c90e1d1 upstream.

SipHash is a 64-bit keyed hash function that is actually a
cryptographically secure PRF, like HMAC. Except SipHash is super fast,
and is meant to be used as a hashtable keyed lookup function, or as a
general PRF for short input use cases, such as sequence numbers or RNG
chaining.

For the first usage:

There are a variety of attacks known as "hashtable poisoning" in which an
attacker forms some data such that the hash of that data will be the
same, and then preceeds to fill up all entries of a hashbucket. This is
a realistic and well-known denial-of-service vector. Currently
hashtables use jhash, which is fast but not secure, and some kind of
rotating key scheme (or none at all, which isn't good). SipHash is meant
as a replacement for jhash in these cases.

There are a modicum of places in the kernel that are vulnerable to
hashtable poisoning attacks, either via userspace vectors or network
vectors, and there's not a reliable mechanism inside the kernel at the
moment to fix it. The first step toward fixing these issues is actually
getting a secure primitive into the kernel for developers to use. Then
we can, bit by bit, port things over to it as deemed appropriate.

While SipHash is extremely fast for a cryptographically secure function,
it is likely a bit slower than the insecure jhash, and so replacements
will be evaluated on a case-by-case basis based on whether or not the
difference in speed is negligible and whether or not the current jhash usage
poses a real security risk.

For the second usage:

A few places in the kernel are using MD5 or SHA1 for creating secure
sequence numbers, syn cookies, port numbers, or fast random numbers.
SipHash is a faster and more fitting, and more secure replacement for MD5
in those situations. Replacing MD5 and SHA1 with SipHash for these uses is
obvious and straight-forward, and so is submitted along with this patch
series. There shouldn't be much of a debate over its efficacy.

Dozens of languages are already using this internally for their hash
tables and PRFs. Some of the BSDs already use this in their kernels.
SipHash is a widely known high-speed solution to a widely known set of
problems, and it's time we catch-up.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: David Laight <David.Laight@aculab.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
Change-Id: I0af6b25995c1d4f77b1f6c3467571abe54ad182e
2020-04-18 17:55:14 +02:00
..
lz4 decompressor: add LZ4 decompressor module 2019-08-05 14:22:45 +02:00
lzo Merge remote-tracking branch 'google-common/deprecated/android-3.4' into lineage-16.0 2019-08-06 11:41:21 +02:00
mpi Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
raid6 Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
reed_solomon
xz XZ: Fix incorrect XZ_BUF_ERROR 2011-10-03 11:40:37 -07:00
zlib_deflate
zlib_inflate
.gitignore
Kconfig decompressor: add LZ4 decompressor module 2019-08-05 14:22:45 +02:00
Kconfig.debug siphash: add cryptographically secure PRF 2020-04-18 17:55:14 +02:00
Kconfig.kgdb
Kconfig.kmemcheck
Makefile siphash: add cryptographically secure PRF 2020-04-18 17:55:14 +02:00
argv_split.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
atomic64.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
atomic64_test.c bug.h: add include of it to various implicit C users 2012-02-29 17:15:08 -05:00
audit.c
average.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
bcd.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
bch.c
bitmap.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
bitrev.c
bsearch.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
btree.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
bug.c bugs, x86: Fix printk levels for panic, softlockups and stack dumps 2012-01-26 21:28:45 +01:00
bust_spinlocks.c
check_signature.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
checksum.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
clz_tab.c lib: Fix multiple definitions of clz_tab 2012-02-02 10:34:23 +11:00
cmdline.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
cordic.c Docs: wording: functions -> algorithm 2011-10-29 21:20:22 +02:00
cpu-notifier-error-inject.c
cpu_rmap.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
cpumask.c lib/cpumask.c: remove __any_online_cpu() 2012-03-28 17:14:35 -07:00
crc-ccitt.c
crc-itu-t.c
crc-t10dif.c
crc7.c
crc8.c
crc16.c
crc32.c crc32: add self-test code for crc32c 2012-03-23 16:58:38 -07:00
crc32defs.h crc32: select an algorithm via Kconfig 2012-03-23 16:58:38 -07:00
ctype.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
debug_locks.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
debugobjects.c debugobjects: Fix selftest for static warnings 2012-03-05 15:49:43 -08:00
dec_and_lock.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
decompress.c decompressor: add LZ4 decompressor module 2019-08-05 14:22:45 +02:00
decompress_bunzip2.c decompress_bunzip2: remove invalid vi modeline 2011-12-06 10:00:05 +01:00
decompress_inflate.c
decompress_unlz4.c decompressor: add LZ4 decompressor module 2019-08-05 14:22:45 +02:00
decompress_unlzma.c treewide: Fix comment and string typo 'bufer' 2011-12-06 09:53:40 +01:00
decompress_unlzo.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
decompress_unxz.c
devres.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
digsig.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
div64.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
dma-debug.c Remove useless get_driver()/put_driver() calls 2012-01-24 16:00:35 -08:00
dump_stack.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
dynamic_debug.c misc: Import SM-G900H kernel source code 2019-08-02 15:14:10 +02:00
dynamic_queue_limits.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
extable.c
fault-inject.c misc: Import SM-G900H kernel source code 2019-08-02 15:14:10 +02:00
find_last_bit.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
find_next_bit.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
flex_array.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
gcd.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
gen_crc32table.c crc32: bolt on crc32c 2012-03-23 16:58:38 -07:00
genalloc.c Merge "genalloc: stop crashing the system when destroying a pool" 2014-03-01 23:17:53 -08:00
halfmd4.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
hexdump.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
hweight.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
idr.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
inflate.c
int_sqrt.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
iomap.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
iomap_copy.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
iommu-helper.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
ioremap.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
irq_regs.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
is_single_threaded.c
kasprintf.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
klist.c klist: del waiter from klist_remove_waiters before wakeup waitting process 2013-10-20 16:48:49 -07:00
kobject.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
kobject_uevent.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
kstrtox.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
kstrtox.h lib/kstrtox: common code between kstrto*() and simple_strto*() functions 2011-10-31 17:30:56 -07:00
lcm.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
libcrc32c.c
list_debug.c misc: Import SM-G900H kernel source code 2019-08-02 15:14:10 +02:00
list_sort.c
llist.c Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
locking-selftest-hardirq.h
locking-selftest-mutex.h
locking-selftest-rlock-hardirq.h
locking-selftest-rlock-softirq.h
locking-selftest-rlock.h
locking-selftest-rsem.h
locking-selftest-softirq.h
locking-selftest-spin-hardirq.h
locking-selftest-spin-softirq.h
locking-selftest-spin.h
locking-selftest-wlock-hardirq.h
locking-selftest-wlock-softirq.h
locking-selftest-wlock.h
locking-selftest-wsem.h
locking-selftest.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
lru_cache.c
md5.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
memory_alloc.c lib: memory_alloc: Support 64-bit physical addresses 2013-04-11 11:29:51 -07:00
nlattr.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
parser.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
pci_iomap.c lib: add NO_GENERIC_PCI_IOPORT_MAP 2012-01-31 23:19:47 +02:00
percpu_counter.c lib/percpu_counter.c: enclose hotplug only variables in hotplug ifdef 2011-10-31 17:30:56 -07:00
plist.c bug.h: add include of it to various implicit C users 2012-02-29 17:15:08 -05:00
prio_heap.c
prio_tree.c prio_tree: introduce prio_set_parent() 2012-03-23 16:58:36 -07:00
proportions.c
qmi_encdec.c lib: qmi: Add api to verify maximum length of a QMI message 2013-01-10 15:26:59 -07:00
qmi_encdec_priv.h lib: qmi: Introduce QMI Encode/Decode library 2012-11-07 16:59:42 -07:00
radix-tree.c radix-tree: add radix_tree_gang_lookup_index 2019-08-05 14:22:46 +02:00
random32.c random32: include missing header file 2019-08-08 15:08:51 +02:00
ratelimit.c misc: Import SM-G900H kernel source code 2019-08-02 15:14:10 +02:00
rational.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
rbtree.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
reciprocal_div.c sch_red: Adaptative RED AQM 2011-12-08 19:52:43 -05:00
rwsem-spinlock.c misc: Import SM-G900H kernel source code 2019-08-02 15:14:10 +02:00
rwsem.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
scatterlist.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
sha1.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
show_mem.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
siphash.c siphash: add cryptographically secure PRF 2020-04-18 17:55:14 +02:00
smp_processor_id.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
sort.c
spinlock_debug.c misc: Import SM-G900H kernel source code 2019-08-02 15:14:10 +02:00
string.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00
string_helpers.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
swiotlb.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
syscall.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
test-kstrtox.c
test_siphash.c siphash: add cryptographically secure PRF 2020-04-18 17:55:14 +02:00
textsearch.c
timerqueue.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
ts_bm.c
ts_fsm.c
ts_kmp.c
uuid.c lib: reduce the use of module.h wherever possible 2012-03-07 15:04:04 -05:00
vsprintf.c Merge tag 'v3.4.113' into lineage-16.0 2019-08-05 14:20:47 +02:00