diff options
| author | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-01-06 07:54:30 -0500 |
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-01-06 08:00:55 -0500 |
| commit | 2a50d805e59ed18265fca44825719f35927af8af (patch) | |
| tree | 1eb56b3c5af351ad0464ec91f70af996de7572df /net | |
| parent | b912b2f8fc71df4c3ffa7a9fe2c2227e8bcdaa07 (diff) | |
Revert "netfilter: avoid get_random_bytes calls"
This reverts commit a42b99a6e329654d376b330de057eff87686d890.
Hannes Frederic Sowa reported some problems with this patch, more specifically
that prandom_u32() may not be ready at boot time, see:
http://marc.info/?l=linux-netdev&m=138896532403533&w=2
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
| -rw-r--r-- | net/netfilter/nfnetlink_log.c | 8 | ||||
| -rw-r--r-- | net/netfilter/nft_hash.c | 2 | ||||
| -rw-r--r-- | net/netfilter/xt_RATEEST.c | 2 | ||||
| -rw-r--r-- | net/netfilter/xt_connlimit.c | 2 | ||||
| -rw-r--r-- | net/netfilter/xt_hashlimit.c | 2 | ||||
| -rw-r--r-- | net/netfilter/xt_recent.c | 2 |
6 files changed, 13 insertions, 5 deletions
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index 7d4254b0dc6b..3c4b69e5fe17 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #include <linux/proc_fs.h> | 28 | #include <linux/proc_fs.h> |
| 29 | #include <linux/security.h> | 29 | #include <linux/security.h> |
| 30 | #include <linux/list.h> | 30 | #include <linux/list.h> |
| 31 | #include <linux/jhash.h> | ||
| 32 | #include <linux/random.h> | ||
| 31 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
| 32 | #include <net/sock.h> | 34 | #include <net/sock.h> |
| 33 | #include <net/netfilter/nf_log.h> | 35 | #include <net/netfilter/nf_log.h> |
| @@ -73,6 +75,7 @@ struct nfulnl_instance { | |||
| 73 | }; | 75 | }; |
| 74 | 76 | ||
| 75 | #define INSTANCE_BUCKETS 16 | 77 | #define INSTANCE_BUCKETS 16 |
| 78 | static unsigned int hash_init; | ||
| 76 | 79 | ||
| 77 | static int nfnl_log_net_id __read_mostly; | 80 | static int nfnl_log_net_id __read_mostly; |
| 78 | 81 | ||
| @@ -1063,6 +1066,11 @@ static int __init nfnetlink_log_init(void) | |||
| 1063 | { | 1066 | { |
| 1064 | int status = -ENOMEM; | 1067 | int status = -ENOMEM; |
| 1065 | 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 | |||
| 1066 | netlink_register_notifier(&nfulnl_rtnl_notifier); | 1074 | netlink_register_notifier(&nfulnl_rtnl_notifier); |
| 1067 | status = nfnetlink_subsys_register(&nfulnl_subsys); | 1075 | status = nfnetlink_subsys_register(&nfulnl_subsys); |
| 1068 | if (status < 0) { | 1076 | if (status < 0) { |
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c index 6aae699aeb46..3d3f8fce10a5 100644 --- a/net/netfilter/nft_hash.c +++ b/net/netfilter/nft_hash.c | |||
| @@ -164,7 +164,7 @@ static int nft_hash_init(const struct nft_set *set, | |||
| 164 | unsigned int cnt, i; | 164 | unsigned int cnt, i; |
| 165 | 165 | ||
| 166 | if (unlikely(!nft_hash_rnd_initted)) { | 166 | if (unlikely(!nft_hash_rnd_initted)) { |
| 167 | nft_hash_rnd = prandom_u32(); | 167 | get_random_bytes(&nft_hash_rnd, 4); |
| 168 | nft_hash_rnd_initted = true; | 168 | nft_hash_rnd_initted = true; |
| 169 | } | 169 | } |
| 170 | 170 | ||
diff --git a/net/netfilter/xt_RATEEST.c b/net/netfilter/xt_RATEEST.c index 190854be7629..370adf622cef 100644 --- a/net/netfilter/xt_RATEEST.c +++ b/net/netfilter/xt_RATEEST.c | |||
| @@ -100,7 +100,7 @@ static int xt_rateest_tg_checkentry(const struct xt_tgchk_param *par) | |||
| 100 | int ret; | 100 | int ret; |
| 101 | 101 | ||
| 102 | if (unlikely(!rnd_inited)) { | 102 | if (unlikely(!rnd_inited)) { |
| 103 | jhash_rnd = prandom_u32(); | 103 | get_random_bytes(&jhash_rnd, sizeof(jhash_rnd)); |
| 104 | rnd_inited = true; | 104 | rnd_inited = true; |
| 105 | } | 105 | } |
| 106 | 106 | ||
diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c index 7671e8214919..c40b2695633b 100644 --- a/net/netfilter/xt_connlimit.c +++ b/net/netfilter/xt_connlimit.c | |||
| @@ -229,7 +229,7 @@ static int connlimit_mt_check(const struct xt_mtchk_param *par) | |||
| 229 | u_int32_t rand; | 229 | u_int32_t rand; |
| 230 | 230 | ||
| 231 | do { | 231 | do { |
| 232 | rand = prandom_u32(); | 232 | get_random_bytes(&rand, sizeof(rand)); |
| 233 | } while (!rand); | 233 | } while (!rand); |
| 234 | cmpxchg(&connlimit_rnd, 0, rand); | 234 | cmpxchg(&connlimit_rnd, 0, rand); |
| 235 | } | 235 | } |
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index d819f62b3b7c..a3910fc2122b 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c | |||
| @@ -177,7 +177,7 @@ dsthash_alloc_init(struct xt_hashlimit_htable *ht, | |||
| 177 | /* initialize hash with random val at the time we allocate | 177 | /* initialize hash with random val at the time we allocate |
| 178 | * the first hashtable entry */ | 178 | * the first hashtable entry */ |
| 179 | if (unlikely(!ht->rnd_initialized)) { | 179 | if (unlikely(!ht->rnd_initialized)) { |
| 180 | ht->rnd = prandom_u32(); | 180 | get_random_bytes(&ht->rnd, sizeof(ht->rnd)); |
| 181 | ht->rnd_initialized = true; | 181 | ht->rnd_initialized = true; |
| 182 | } | 182 | } |
| 183 | 183 | ||
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c index bfdc29f1a04a..1e657cf715c4 100644 --- a/net/netfilter/xt_recent.c +++ b/net/netfilter/xt_recent.c | |||
| @@ -334,7 +334,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par, | |||
| 334 | size_t sz; | 334 | size_t sz; |
| 335 | 335 | ||
| 336 | if (unlikely(!hash_rnd_inited)) { | 336 | if (unlikely(!hash_rnd_inited)) { |
| 337 | hash_rnd = prandom_u32(); | 337 | get_random_bytes(&hash_rnd, sizeof(hash_rnd)); |
| 338 | hash_rnd_inited = true; | 338 | hash_rnd_inited = true; |
| 339 | } | 339 | } |
| 340 | if (info->check_set & ~XT_RECENT_VALID_FLAGS) { | 340 | if (info->check_set & ~XT_RECENT_VALID_FLAGS) { |
