1. 09 10月, 2015 35 次提交
  2. 08 10月, 2015 5 次提交
    • D
      Merge branch 'bpf_random32' · df718423
      David S. Miller 提交于
      Daniel Borkmann says:
      
      ====================
      BPF/random32 updates
      
      BPF update to split the prandom state apart, and to move the
      *once helpers to the core. For details, please see individual
      patches. Given the changes and since it's in the tree for
      quite some time, net-next is a better choice in our opinion.
      
      v1 -> v2:
       - Make DO_ONCE() type-safe, remove the kvec helper. Credits
         go to Alexei Starovoitov for the __VA_ARGS__ hint, thanks!
       - Add a comment to the DO_ONCE() helper as suggested by Alexei.
       - Rework prandom_init_once() helper to the new API.
       - Keep Alexei's Acked-by on the last patch.
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      df718423
    • D
      bpf: split state from prandom_u32() and consolidate {c, e}BPF prngs · 3ad00405
      Daniel Borkmann 提交于
      While recently arguing on a seccomp discussion that raw prandom_u32()
      access shouldn't be exposed to unpriviledged user space, I forgot the
      fact that SKF_AD_RANDOM extension actually already does it for some time
      in cBPF via commit 4cd3675e ("filter: added BPF random opcode").
      
      Since prandom_u32() is being used in a lot of critical networking code,
      lets be more conservative and split their states. Furthermore, consolidate
      eBPF and cBPF prandom handlers to use the new internal PRNG. For eBPF,
      bpf_get_prandom_u32() was only accessible for priviledged users, but
      should that change one day, we also don't want to leak raw sequences
      through things like eBPF maps.
      
      One thought was also to have own per bpf_prog states, but due to ABI
      reasons this is not easily possible, i.e. the program code currently
      cannot access bpf_prog itself, and copying the rnd_state to/from the
      stack scratch space whenever a program uses the prng seems not really
      worth the trouble and seems too hacky. If needed, taus113 could in such
      cases be implemented within eBPF using a map entry to keep the state
      space, or get_random_bytes() could become a second helper in cases where
      performance would not be critical.
      
      Both sides can trigger a one-time late init via prandom_init_once() on
      the shared state. Performance-wise, there should even be a tiny gain
      as bpf_user_rnd_u32() saves one function call. The PRNG needs to live
      inside the BPF core since kernels could have a NET-less config as well.
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Chema Gonzalez <chema@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3ad00405
    • D
      random32: add prandom_init_once helper for own rngs · 897ece56
      Daniel Borkmann 提交于
      Add a prandom_init_once() facility that works on the rnd_state, so that
      users that are keeping their own state independent from prandom_u32() can
      initialize their taus113 per cpu states.
      
      The motivation here is similar to net_get_random_once(): initialize the
      state as late as possible in the hope that enough entropy has been
      collected for the seeding. prandom_init_once() makes use of the recently
      introduced prandom_seed_full_state() helper and is generic enough so that
      it could also be used on fast-paths due to the DO_ONCE().
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      897ece56
    • D
      random32: add prandom_seed_full_state helper · 0dd50d1b
      Daniel Borkmann 提交于
      Factor out the full reseed handling code that populates the state
      through get_random_bytes() and runs prandom_warmup(). The resulting
      prandom_seed_full_state() will be used later on in more than the
      current __prandom_reseed() user. Fix also two minor whitespace
      issues along the way.
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0dd50d1b
    • H
      once: make helper generic for calling functions once · c90aeb94
      Hannes Frederic Sowa 提交于
      Make the get_random_once() helper generic enough, so that functions
      in general would only be called once, where one user of this is then
      net_get_random_once().
      
      The only implementation specific call is to get_random_bytes(), all
      the rest of this *_once() facility would be duplicated among different
      subsystems otherwise. The new DO_ONCE() helper will be used by prandom()
      later on, but might also be useful for other scenarios/subsystems as
      well where a one-time initialization in often-called, possibly fast
      path code could occur.
      Signed-off-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c90aeb94