mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Bligh - linux-kernel <linux-kernel@alex.org.uk>
To: linux-kernel@vger.kernel.org
Cc: Alex Bligh - linux-kernel <linux-kernel@alex.org.uk>,
	Theodore Tso <tytso@mit.edu>
Subject: /dev/random entropy calcs - patch [not related to net devices]
Date: Tue, 21 Aug 2001 23:40:43 +0100	[thread overview]
Message-ID: <9547398.998437243@[169.254.198.40]> (raw)

1. Anyone have a problem with using xtime rather
   than jiffies on architectures which don't support cycle
   counters? (completely untested patch attached to illustrate)

2. Anyone have any problem changing fs/proc/proc_misc.c to
   register /proc/interrupts to be 0600 instead of 0644 to help
   prevent entropy attacks that way?

--
Alex Bligh

--- drivers/char/random.c.keep       Sat Feb 17 00:02:36 2001
+++ drivers/char/random.c     Tue Aug 21 23:19:17 2001
@@ -710,16 +710,27 @@
        int             entropy = 0;

 #if defined (__i386__)
+       /* If possible, use the clock cycle counter */
        if ( test_bit(X86_FEATURE_TSC, &boot_cpu_data.x86_capability) ) {
                __u32 high;
                __asm__(".byte 0x0f,0x31"
                        :"=a" (time), "=d" (high));
                num ^= high;
        } else {
-               time = jiffies;
+               time = (__u32)(xtime.tv_usec) ^ (__u32)(xtime.tv_sec);
        }
 #else
-       time = jiffies;
+       /* If we can't get the clock cycle counter, get the number
+        * of elapsed microseconds. Note:
+        * - we don't need the xtime spinlock as we are only reading
+        *   one half (even then, the odd SMP race is only going to
+        *   add to entropy)
+        * - this may indeed wrap; but so could the original cycle
+        *   counter, and as us occur less frequently than clock cycles,
+        *   it's less of a problem. In any case it would underestimate
+        *   entropy on a wrap.
+        */
+       time = (__u32)(xtime.tv_usec) ^ (__u32)(xtime.tv_sec);
 #endif

        /*


             reply	other threads:[~2001-08-21 22:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-21 22:40 Alex Bligh - linux-kernel [this message]
2001-08-21 22:54 ` David Schwartz
     [not found] <9547398.998437243@_169.254.198.40_>
2001-08-23  1:53 ` Ton Hospel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='9547398.998437243@[169.254.198.40]' \
    --to=linux-kernel@alex.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®