Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1244058

Re: Updated scalable urandom patchkit

From "George Spelvin" <linux@horizon.com>
Newsgroups linux.kernel
Subject Re: Updated scalable urandom patchkit
Date 2015-10-11 06:40 +0200
Message-ID <qigAp-5WN-3@gated-at.bofh.it> (permalink)
References <qieIh-3cX-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Damn, I bow before the master.  That is a much neater solution
than mine; I had assumed a lock was required for writing.

While it's good enough for benchmarking, there are a few leftover
problems I mention so they don't get missed.

One is the final write back of add_ptr on the last line of
_mix_pool_bytes.  It actually writes i, which includes the per-cpu nonce,
and will have it jumping all over without the steady progression that
the mixing polynomial assumes.

(There's a similar, lesser problem with input_rotate.)

The second, less obvious, problem is that by calling _mix_pool_bytes
completely lockless, there's the risk that it will race with and overwrite
the addition of new seed material to the pool.

The add-back is not critical, and races between two writers don't really
do any harm.  But seed entropy is valuable.

And unfortunately, transferring 256 bits (32 bytes) to the output pool
will try to write every word, so *any* concurrent add-back is risky; there's
no "safe" part of the pool that can be accessed lockless.

(The first crude hack that comes to mind is to double the size
of the output pool, without increasing its nominal capacity, and
do seeding and add-back to different halves.  Hopefully there's
something more elegant.)


Two minor suggestions about is_nonblock:
1) Rather than using (r == &nonblocking_pool), how about !r->limit?

2) Would you mind making is_nonblock bool?

   I know back before the sacred text of the prophets Kernighan and
   Ritchie was corrupted by modern heresies, we used "int" for everything,
   and we liked it.  5 miles in the snow, uphill both ways, yadda yadda.

   But I like to document range restrictions as much as possible, and "bool"
   makes it clearer to both the compiler and the reader of the code.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-10 21:00 +0200
  Re: Updated scalable urandom patchkit Theodore Ts'o <tytso@mit.edu> - 2015-10-11 04:40 +0200
    Re: Updated scalable urandom patchkit Theodore Ts'o <tytso@mit.edu> - 2015-10-11 05:00 +0200
    Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-11 06:40 +0200
      Re: Updated scalable urandom patchkit Theodore Ts'o <tytso@mit.edu> - 2015-10-12 00:30 +0200
        Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-12 02:20 +0200
          Re: Updated scalable urandom patchkit Theodore Ts'o <tytso@mit.edu> - 2015-10-12 06:10 +0200
            Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-12 09:50 +0200
              Re: Updated scalable urandom patchkit Theodore Ts'o <tytso@mit.edu> - 2015-10-12 16:00 +0200
                Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-12 22:40 +0200
                Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-12 22:40 +0200
                Re: Updated scalable urandom patchkit Theodore Ts'o <tytso@mit.edu> - 2015-10-13 04:50 +0200
                Re: Updated scalable urandom patchkit Raymond Jennings <shentino@gmail.com> - 2015-10-13 06:30 +0200
                Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-13 10:00 +0200
                Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-13 08:30 +0200
                Re: Updated scalable urandom patchkit Andi Kleen <andi@firstfloor.org> - 2015-10-13 18:30 +0200
                Re: Updated scalable urandom patchkit "George Spelvin" <linux@horizon.com> - 2015-10-13 23:20 +0200
                Re: Updated scalable urandom patchkit Andi Kleen <andi@firstfloor.org> - 2015-10-14 04:20 +0200
                [RFC PATCH 0/4] Alternate sclable urandom patchset "George Spelvin" <linux@horizon.com> - 2015-10-16 07:30 +0200
                [RFC PATCH 2/4] random: Remove two unused arguments from extract_entropy() "George Spelvin" <linux@horizon.com> - 2015-10-16 07:40 +0200
                [RFC PATCH 4/4] random: Make non-blocking mixback non-blocking "George Spelvin" <linux@horizon.com> - 2015-10-16 07:40 +0200
                [RFC PATCH 3/4] random: Only do mixback once per read "George Spelvin" <linux@horizon.com> - 2015-10-16 07:40 +0200
                Re: [RFC PATCH 3/4] random: Only do mixback once per read kbuild test robot <lkp@intel.com> - 2015-10-16 08:20 +0200
                Re: [RFC PATCH 3/4] random: Only do mixback once per read "George Spelvin" <linux@horizon.com> - 2015-10-16 10:20 +0200

csiph-web