Commit a42b99a6e329654d376b330de057eff87686d890
Committed by
Pablo Neira Ayuso
1 parent
8cf4d6a224
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
netfilter: avoid get_random_bytes calls
All these users need an initial seed value for jhash, prandom is perfectly fine. This avoids draining the entropy pool where its not strictly required. nfnetlink_log did not use the random value at all. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Showing 6 changed files with 5 additions and 13 deletions Side-by-side Diff
net/netfilter/nfnetlink_log.c
... | ... | @@ -28,8 +28,6 @@ |
28 | 28 | #include <linux/proc_fs.h> |
29 | 29 | #include <linux/security.h> |
30 | 30 | #include <linux/list.h> |
31 | -#include <linux/jhash.h> | |
32 | -#include <linux/random.h> | |
33 | 31 | #include <linux/slab.h> |
34 | 32 | #include <net/sock.h> |
35 | 33 | #include <net/netfilter/nf_log.h> |
... | ... | @@ -75,7 +73,6 @@ |
75 | 73 | }; |
76 | 74 | |
77 | 75 | #define INSTANCE_BUCKETS 16 |
78 | -static unsigned int hash_init; | |
79 | 76 | |
80 | 77 | static int nfnl_log_net_id __read_mostly; |
81 | 78 | |
... | ... | @@ -1065,11 +1062,6 @@ |
1065 | 1062 | static int __init nfnetlink_log_init(void) |
1066 | 1063 | { |
1067 | 1064 | int status = -ENOMEM; |
1068 | - | |
1069 | - /* it's not really all that important to have a random value, so | |
1070 | - * we can do this from the init function, even if there hasn't | |
1071 | - * been that much entropy yet */ | |
1072 | - get_random_bytes(&hash_init, sizeof(hash_init)); | |
1073 | 1065 | |
1074 | 1066 | netlink_register_notifier(&nfulnl_rtnl_notifier); |
1075 | 1067 | status = nfnetlink_subsys_register(&nfulnl_subsys); |
net/netfilter/nft_hash.c
net/netfilter/xt_RATEEST.c
net/netfilter/xt_connlimit.c
net/netfilter/xt_hashlimit.c
... | ... | @@ -177,7 +177,7 @@ |
177 | 177 | /* initialize hash with random val at the time we allocate |
178 | 178 | * the first hashtable entry */ |
179 | 179 | if (unlikely(!ht->rnd_initialized)) { |
180 | - get_random_bytes(&ht->rnd, sizeof(ht->rnd)); | |
180 | + ht->rnd = prandom_u32(); | |
181 | 181 | ht->rnd_initialized = true; |
182 | 182 | } |
183 | 183 |
net/netfilter/xt_recent.c