mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
The /dev/random changes for 3.13 including a number of improvements in
the following areas: performance, avoiding waste of entropy, better tracking of entropy estimates, support for non-x86 platforms that have a register which can't be used for fine-grained timekeeping, but which might be good enough for the random driver. Also add some printk's so that we can see how quickly /dev/urandom can get initialized, and when programs try to use /dev/urandom before it is fully initialized (since this could be a security issue). This shouldn't be an issue on x86 desktop/laptops --- a test on my Lenovo T430s laptop shows that /dev/urandom is getting fully initialized approximately two seconds before the root file system is mounted read/write --- this may be an issue with ARM and MIPS embedded/mobile systems, though. These printk's will be a useful canary before potentially adding a future change to start blocking processes which try to read from /dev/urandom before it is initialized, which is something FreeBSD does already for security reasons, and which security folks have been agitating for Linux to also adopt. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAABCAAGBQJShC4MAAoJENNvdpvBGATwC0QQAMujsIxTZnsHwQrbb5eJf1kD 74TwQyEfWw5qnGQrc8JOoAbe1MG7C4QlfHxRsWxvCD8G+Mft4Q5ZgZOt0/ecAGD6 Tid58EaZGSfK9+YE6jgvJFekQADCREdPSxBASJ3cECT6dXXBX9IqR9gbAK02mM+w QZdbgWBMsPJZiHSsCNeRbZ9oIiPdcNDsMJwzJhirPUeAnKCaX3z+LWc3XcMw7wYi q5cSl0ENZd6QsBKs37A1ol5BtLEsoot2t3HKdnpOBsDQKSJ712KduwN5jUfs6h9D 0fqmVHwfKsge+D8/3NgBKz+yWLQnGkuB4Ibo+09BZXwH3rYU1/gKm0iLNi0yQ5fV 73bn4pqF6cZdDNgj0Ic+MyYAW+S/NOQ6TcF/3eSAPW6z/wHZOfZ2njCh1GEHBOKI 6iZZu+Ek7QyFJ/z5Fr1bXFJR7V99r7hRD3gwMCMZ/mjhloB2cyD0a2A9kFP85ykI I4tFEnq0FpX/K60ag4hiLnqVx/TsmbdMoz+8OpQckHgQJrZMuRRf1d+T4au47Y6K uXGLpSuvkALYW2koo2OoO2d873N/89fqFL8lI8Iy0YlgAxxxm++gl1Mql/E1wPOa 5jB0lW/jex/CquE7meTgRlM/fTU/HVbe3608ZNUYBJUHS9K/PaSnCCu2ya8/TsSW xeVS/vMnNvtGerdEIyKm =wla0 -----END PGP SIGNATURE----- Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random Pull /dev/random changes from Ted Ts'o: "The /dev/random changes for 3.13 including a number of improvements in the following areas: performance, avoiding waste of entropy, better tracking of entropy estimates, support for non-x86 platforms that have a register which can't be used for fine-grained timekeeping, but which might be good enough for the random driver. Also add some printk's so that we can see how quickly /dev/urandom can get initialized, and when programs try to use /dev/urandom before it is fully initialized (since this could be a security issue). This shouldn't be an issue on x86 desktop/laptops --- a test on my Lenovo T430s laptop shows that /dev/urandom is getting fully initialized approximately two seconds before the root file system is mounted read/write --- this may be an issue with ARM and MIPS embedded/mobile systems, though. These printk's will be a useful canary before potentially adding a future change to start blocking processes which try to read from /dev/urandom before it is initialized, which is something FreeBSD does already for security reasons, and which security folks have been agitating for Linux to also adopt" * tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random: random: add debugging code to detect early use of get_random_bytes() random: initialize the last_time field in struct timer_rand_state random: don't zap entropy count in rand_initialize() random: printk notifications for urandom pool initialization random: make add_timer_randomness() fill the nonblocking pool first random: convert DEBUG_ENT to tracepoints random: push extra entropy to the output pools random: drop trickle mode random: adjust the generator polynomials in the mixing function slightly random: speed up the fast_mix function by a factor of four random: cap the rate which the /dev/urandom pool gets reseeded random: optimize the entropy_store structure random: optimize spinlock use in add_device_randomness() random: fix the tracepoint for get_random_bytes(_arch) random: account for entropy loss due to overwrites random: allow fractional bits to be tracked random: statically compute poolbitshift, poolbytes, poolbits random: mix in architectural randomness earlier in extract_buf()
This commit is contained in:
commit
0891ad829d
2 changed files with 598 additions and 254 deletions
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,25 @@
|
|||
#include <linux/writeback.h>
|
||||
#include <linux/tracepoint.h>
|
||||
|
||||
TRACE_EVENT(add_device_randomness,
|
||||
TP_PROTO(int bytes, unsigned long IP),
|
||||
|
||||
TP_ARGS(bytes, IP),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( int, bytes )
|
||||
__field(unsigned long, IP )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->bytes = bytes;
|
||||
__entry->IP = IP;
|
||||
),
|
||||
|
||||
TP_printk("bytes %d caller %pF",
|
||||
__entry->bytes, (void *)__entry->IP)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(random__mix_pool_bytes,
|
||||
TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
|
||||
|
||||
|
@ -68,7 +87,112 @@ TRACE_EVENT(credit_entropy_bits,
|
|||
(void *)__entry->IP)
|
||||
);
|
||||
|
||||
TRACE_EVENT(get_random_bytes,
|
||||
TRACE_EVENT(push_to_pool,
|
||||
TP_PROTO(const char *pool_name, int pool_bits, int input_bits),
|
||||
|
||||
TP_ARGS(pool_name, pool_bits, input_bits),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( const char *, pool_name )
|
||||
__field( int, pool_bits )
|
||||
__field( int, input_bits )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->pool_name = pool_name;
|
||||
__entry->pool_bits = pool_bits;
|
||||
__entry->input_bits = input_bits;
|
||||
),
|
||||
|
||||
TP_printk("%s: pool_bits %d input_pool_bits %d",
|
||||
__entry->pool_name, __entry->pool_bits,
|
||||
__entry->input_bits)
|
||||
);
|
||||
|
||||
TRACE_EVENT(debit_entropy,
|
||||
TP_PROTO(const char *pool_name, int debit_bits),
|
||||
|
||||
TP_ARGS(pool_name, debit_bits),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( const char *, pool_name )
|
||||
__field( int, debit_bits )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->pool_name = pool_name;
|
||||
__entry->debit_bits = debit_bits;
|
||||
),
|
||||
|
||||
TP_printk("%s: debit_bits %d", __entry->pool_name,
|
||||
__entry->debit_bits)
|
||||
);
|
||||
|
||||
TRACE_EVENT(add_input_randomness,
|
||||
TP_PROTO(int input_bits),
|
||||
|
||||
TP_ARGS(input_bits),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( int, input_bits )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->input_bits = input_bits;
|
||||
),
|
||||
|
||||
TP_printk("input_pool_bits %d", __entry->input_bits)
|
||||
);
|
||||
|
||||
TRACE_EVENT(add_disk_randomness,
|
||||
TP_PROTO(dev_t dev, int input_bits),
|
||||
|
||||
TP_ARGS(dev, input_bits),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( dev_t, dev )
|
||||
__field( int, input_bits )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->dev = dev;
|
||||
__entry->input_bits = input_bits;
|
||||
),
|
||||
|
||||
TP_printk("dev %d,%d input_pool_bits %d", MAJOR(__entry->dev),
|
||||
MINOR(__entry->dev), __entry->input_bits)
|
||||
);
|
||||
|
||||
TRACE_EVENT(xfer_secondary_pool,
|
||||
TP_PROTO(const char *pool_name, int xfer_bits, int request_bits,
|
||||
int pool_entropy, int input_entropy),
|
||||
|
||||
TP_ARGS(pool_name, xfer_bits, request_bits, pool_entropy,
|
||||
input_entropy),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( const char *, pool_name )
|
||||
__field( int, xfer_bits )
|
||||
__field( int, request_bits )
|
||||
__field( int, pool_entropy )
|
||||
__field( int, input_entropy )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->pool_name = pool_name;
|
||||
__entry->xfer_bits = xfer_bits;
|
||||
__entry->request_bits = request_bits;
|
||||
__entry->pool_entropy = pool_entropy;
|
||||
__entry->input_entropy = input_entropy;
|
||||
),
|
||||
|
||||
TP_printk("pool %s xfer_bits %d request_bits %d pool_entropy %d "
|
||||
"input_entropy %d", __entry->pool_name, __entry->xfer_bits,
|
||||
__entry->request_bits, __entry->pool_entropy,
|
||||
__entry->input_entropy)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(random__get_random_bytes,
|
||||
TP_PROTO(int nbytes, unsigned long IP),
|
||||
|
||||
TP_ARGS(nbytes, IP),
|
||||
|
@ -86,6 +210,18 @@ TRACE_EVENT(get_random_bytes,
|
|||
TP_printk("nbytes %d caller %pF", __entry->nbytes, (void *)__entry->IP)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(random__get_random_bytes, get_random_bytes,
|
||||
TP_PROTO(int nbytes, unsigned long IP),
|
||||
|
||||
TP_ARGS(nbytes, IP)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(random__get_random_bytes, get_random_bytes_arch,
|
||||
TP_PROTO(int nbytes, unsigned long IP),
|
||||
|
||||
TP_ARGS(nbytes, IP)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(random__extract_entropy,
|
||||
TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
|
||||
unsigned long IP),
|
||||
|
@ -126,7 +262,52 @@ DEFINE_EVENT(random__extract_entropy, extract_entropy_user,
|
|||
TP_ARGS(pool_name, nbytes, entropy_count, IP)
|
||||
);
|
||||
|
||||
TRACE_EVENT(random_read,
|
||||
TP_PROTO(int got_bits, int need_bits, int pool_left, int input_left),
|
||||
|
||||
TP_ARGS(got_bits, need_bits, pool_left, input_left),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( int, got_bits )
|
||||
__field( int, need_bits )
|
||||
__field( int, pool_left )
|
||||
__field( int, input_left )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->got_bits = got_bits;
|
||||
__entry->need_bits = need_bits;
|
||||
__entry->pool_left = pool_left;
|
||||
__entry->input_left = input_left;
|
||||
),
|
||||
|
||||
TP_printk("got_bits %d still_needed_bits %d "
|
||||
"blocking_pool_entropy_left %d input_entropy_left %d",
|
||||
__entry->got_bits, __entry->got_bits, __entry->pool_left,
|
||||
__entry->input_left)
|
||||
);
|
||||
|
||||
TRACE_EVENT(urandom_read,
|
||||
TP_PROTO(int got_bits, int pool_left, int input_left),
|
||||
|
||||
TP_ARGS(got_bits, pool_left, input_left),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field( int, got_bits )
|
||||
__field( int, pool_left )
|
||||
__field( int, input_left )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->got_bits = got_bits;
|
||||
__entry->pool_left = pool_left;
|
||||
__entry->input_left = input_left;
|
||||
),
|
||||
|
||||
TP_printk("got_bits %d nonblocking_pool_entropy_left %d "
|
||||
"input_entropy_left %d", __entry->got_bits,
|
||||
__entry->pool_left, __entry->input_left)
|
||||
);
|
||||
|
||||
#endif /* _TRACE_RANDOM_H */
|
||||
|
||||
|
|
Loading…
Reference in a new issue