Skip to content

Commit

Permalink
ipv4: use siphash instead of Jenkins in fnhe_hashfun()
Browse files Browse the repository at this point in the history
ANBZ: torvalds#535

commit 6457378 ("ipv4: use siphash instead of Jenkins in fnhe_hashfun()")

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: d546c62 ("ipv4: harden fnhe_hashfun()")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: Keyu Man <[email protected]>
Cc: Willy Tarreau <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Xuan Zhuo <[email protected]>
Acked-by: Dust Li <[email protected]>
  • Loading branch information
Eric Dumazet authored and Dust.Li committed Feb 23, 2022
1 parent 0b19032 commit e87fd0f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,14 +612,14 @@ static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash)
return oldest;
}

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

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

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

0 comments on commit e87fd0f

Please sign in to comment.