Skip to content

Commit e7b519b

Browse files
strssndktndavem330
authored andcommitted
ipv4: initialize ip4_frags hash secret as late as possible
Defer the generation of the first hash secret for the ipv4 fragmentation cache as late as possible. ip4_frags.rnd gets initial seeded by inet_frags_init and regulary reseeded by inet_frag_secret_rebuild. Either we call ipqhashfn directly from ip_fragment.c in which case we initialize the secret directly. If we first get called by inet_frag_secret_rebuild we install a new secret by a manual call to get_random_bytes. This secret will be overwritten as soon as the first call to ipqhashfn happens. This is safe because we won't race while publishing the new secrets with anyone else. Cc: Eric Dumazet <edumazet@google.com> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent df33db0 commit e7b519b

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎net/ipv4/ip_fragment.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct ip4_create_arg {
106106

107107
static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot)
108108
{
109+
net_get_random_once(&ip4_frags.rnd, sizeof(ip4_frags.rnd));
109110
return jhash_3words((__force u32)id << 16 | prot,
110111
(__force u32)saddr, (__force u32)daddr,
111112
ip4_frags.rnd) & (INETFRAGS_HASHSZ - 1);

0 commit comments

Comments
 (0)