Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ba6c163 authored by Eric Dumazet's avatar Eric Dumazet Committed by Greg Kroah-Hartman
Browse files

ipv4: use siphash instead of Jenkins in fnhe_hashfun()



commit 6457378fe796815c973f631a1904e147d6ee33b1 upstream.

A group of security researchers brought to our attention
the weakness of hash function used in fnhe_hashfun().

Lets use siphash instead of Jenkins Hash, to considerably
reduce security risks.

Also remove the inline keyword, this really is distracting.

Fixes: d546c621 ("ipv4: harden fnhe_hashfun()")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reported-by: default avatarKeyu Man <kman001@ucr.edu>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[OP: adjusted context for 5.4 stable]
Signed-off-by: default avatarOvidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3f439c23
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -631,14 +631,14 @@ static void fnhe_remove_oldest(struct fnhe_hash_bucket *hash)
	kfree_rcu(oldest, rcu);
	kfree_rcu(oldest, rcu);
}
}


static inline u32 fnhe_hashfun(__be32 daddr)
static u32 fnhe_hashfun(__be32 daddr)
{
{
	static u32 fnhe_hashrnd __read_mostly;
	static siphash_key_t fnhe_hash_key __read_mostly;
	u32 hval;
	u64 hval;


	net_get_random_once(&fnhe_hashrnd, sizeof(fnhe_hashrnd));
	net_get_random_once(&fnhe_hash_key, sizeof(fnhe_hash_key));
	hval = jhash_1word((__force u32) daddr, fnhe_hashrnd);
	hval = siphash_1u32((__force u32)daddr, &fnhe_hash_key);
	return hash_32(hval, FNHE_HASH_SHIFT);
	return hash_64(hval, FNHE_HASH_SHIFT);
}
}


static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe)
static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe)