提交 b4b01674 编写于 作者: J Jason A. Donenfeld 提交者: Zheng Zengkai

random: rather than entropy_store abstraction, use global

stable inclusion
from stable-v5.10.119
commit 8cc5260c19da9ff46cd34e951d0cdbbc3733e418
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6BB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8cc5260c19da9ff46cd34e951d0cdbbc3733e418

--------------------------------

commit 90ed1e67 upstream.

Originally, the RNG used several pools, so having things abstracted out
over a generic entropy_store object made sense. These days, there's only
one input pool, and then an uneven mix of usage via the abstraction and
usage via &input_pool. Rather than this uneasy mixture, just get rid of
the abstraction entirely and have things always use the global. This
simplifies the code and makes reading it a bit easier.
Reviewed-by: NDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 6b1640d6
此差异已折叠。
...@@ -28,80 +28,71 @@ TRACE_EVENT(add_device_randomness, ...@@ -28,80 +28,71 @@ TRACE_EVENT(add_device_randomness,
); );
DECLARE_EVENT_CLASS(random__mix_pool_bytes, DECLARE_EVENT_CLASS(random__mix_pool_bytes,
TP_PROTO(const char *pool_name, int bytes, unsigned long IP), TP_PROTO(int bytes, unsigned long IP),
TP_ARGS(pool_name, bytes, IP), TP_ARGS(bytes, IP),
TP_STRUCT__entry( TP_STRUCT__entry(
__field( const char *, pool_name )
__field( int, bytes ) __field( int, bytes )
__field(unsigned long, IP ) __field(unsigned long, IP )
), ),
TP_fast_assign( TP_fast_assign(
__entry->pool_name = pool_name;
__entry->bytes = bytes; __entry->bytes = bytes;
__entry->IP = IP; __entry->IP = IP;
), ),
TP_printk("%s pool: bytes %d caller %pS", TP_printk("input pool: bytes %d caller %pS",
__entry->pool_name, __entry->bytes, (void *)__entry->IP) __entry->bytes, (void *)__entry->IP)
); );
DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes, DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes,
TP_PROTO(const char *pool_name, int bytes, unsigned long IP), TP_PROTO(int bytes, unsigned long IP),
TP_ARGS(pool_name, bytes, IP) TP_ARGS(bytes, IP)
); );
DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes_nolock, DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes_nolock,
TP_PROTO(const char *pool_name, int bytes, unsigned long IP), TP_PROTO(int bytes, unsigned long IP),
TP_ARGS(pool_name, bytes, IP) TP_ARGS(bytes, IP)
); );
TRACE_EVENT(credit_entropy_bits, TRACE_EVENT(credit_entropy_bits,
TP_PROTO(const char *pool_name, int bits, int entropy_count, TP_PROTO(int bits, int entropy_count, unsigned long IP),
unsigned long IP),
TP_ARGS(pool_name, bits, entropy_count, IP), TP_ARGS(bits, entropy_count, IP),
TP_STRUCT__entry( TP_STRUCT__entry(
__field( const char *, pool_name )
__field( int, bits ) __field( int, bits )
__field( int, entropy_count ) __field( int, entropy_count )
__field(unsigned long, IP ) __field(unsigned long, IP )
), ),
TP_fast_assign( TP_fast_assign(
__entry->pool_name = pool_name;
__entry->bits = bits; __entry->bits = bits;
__entry->entropy_count = entropy_count; __entry->entropy_count = entropy_count;
__entry->IP = IP; __entry->IP = IP;
), ),
TP_printk("%s pool: bits %d entropy_count %d caller %pS", TP_printk("input pool: bits %d entropy_count %d caller %pS",
__entry->pool_name, __entry->bits, __entry->bits, __entry->entropy_count, (void *)__entry->IP)
__entry->entropy_count, (void *)__entry->IP)
); );
TRACE_EVENT(debit_entropy, TRACE_EVENT(debit_entropy,
TP_PROTO(const char *pool_name, int debit_bits), TP_PROTO(int debit_bits),
TP_ARGS(pool_name, debit_bits), TP_ARGS( debit_bits),
TP_STRUCT__entry( TP_STRUCT__entry(
__field( const char *, pool_name )
__field( int, debit_bits ) __field( int, debit_bits )
), ),
TP_fast_assign( TP_fast_assign(
__entry->pool_name = pool_name;
__entry->debit_bits = debit_bits; __entry->debit_bits = debit_bits;
), ),
TP_printk("%s: debit_bits %d", __entry->pool_name, TP_printk("input pool: debit_bits %d", __entry->debit_bits)
__entry->debit_bits)
); );
TRACE_EVENT(add_input_randomness, TRACE_EVENT(add_input_randomness,
...@@ -170,36 +161,31 @@ DEFINE_EVENT(random__get_random_bytes, get_random_bytes_arch, ...@@ -170,36 +161,31 @@ DEFINE_EVENT(random__get_random_bytes, get_random_bytes_arch,
); );
DECLARE_EVENT_CLASS(random__extract_entropy, DECLARE_EVENT_CLASS(random__extract_entropy,
TP_PROTO(const char *pool_name, int nbytes, int entropy_count, TP_PROTO(int nbytes, int entropy_count, unsigned long IP),
unsigned long IP),
TP_ARGS(pool_name, nbytes, entropy_count, IP), TP_ARGS(nbytes, entropy_count, IP),
TP_STRUCT__entry( TP_STRUCT__entry(
__field( const char *, pool_name )
__field( int, nbytes ) __field( int, nbytes )
__field( int, entropy_count ) __field( int, entropy_count )
__field(unsigned long, IP ) __field(unsigned long, IP )
), ),
TP_fast_assign( TP_fast_assign(
__entry->pool_name = pool_name;
__entry->nbytes = nbytes; __entry->nbytes = nbytes;
__entry->entropy_count = entropy_count; __entry->entropy_count = entropy_count;
__entry->IP = IP; __entry->IP = IP;
), ),
TP_printk("%s pool: nbytes %d entropy_count %d caller %pS", TP_printk("input pool: nbytes %d entropy_count %d caller %pS",
__entry->pool_name, __entry->nbytes, __entry->entropy_count, __entry->nbytes, __entry->entropy_count, (void *)__entry->IP)
(void *)__entry->IP)
); );
DEFINE_EVENT(random__extract_entropy, extract_entropy, DEFINE_EVENT(random__extract_entropy, extract_entropy,
TP_PROTO(const char *pool_name, int nbytes, int entropy_count, TP_PROTO(int nbytes, int entropy_count, unsigned long IP),
unsigned long IP),
TP_ARGS(pool_name, nbytes, entropy_count, IP) TP_ARGS(nbytes, entropy_count, IP)
); );
TRACE_EVENT(urandom_read, TRACE_EVENT(urandom_read,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册