]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: use get_random_u32 instead of prandom
authorFlorian Westphal <fw@strlen.de>
Wed, 18 May 2022 18:15:31 +0000 (20:15 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 8 Jun 2022 10:30:59 +0000 (12:30 +0200)
commit46bcd0e658b4b949ed03b83df54a14b15f11d165
treeccc6d92dc74c8fc91dc915f6b10adfb21a7e771c
parent5301ba81dc9d662b61de168df93884f89e233806
netfilter: use get_random_u32 instead of prandom

bh might occur while updating per-cpu rnd_state from user context,
ie. local_out path.

BUG: using smp_processor_id() in preemptible [00000000] code: nginx/2725
caller is nft_ng_random_eval+0x24/0x54 [nft_numgen]
Call Trace:
 check_preemption_disabled+0xde/0xe0
 nft_ng_random_eval+0x24/0x54 [nft_numgen]

Use the random driver instead, this also avoids need for local prandom
state. Moreover, prandom now uses the random driver since c009001b3ca7
("random32: use real rng for non-deterministic randomness").

Based on earlier patch from Pablo Neira.

Fixes: fbdcd787eba3 ("netfilter: nft_meta: place prandom handling in a helper")
Fixes: 88be92da0192 ("netfilter: nft_numgen: add map lookups for numgen random operations")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_meta.c
net/netfilter/nft_numgen.c