All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Hannes Frederic Sowa <hannes@stressinduktion.org>,
	Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, alexei.starovoitov@gmail.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH net] bpf: rather use get_random_int for randomizations
Date: Wed, 18 May 2016 16:14:16 +0200	[thread overview]
Message-ID: <573C78B8.2050400@iogearbox.net> (raw)
In-Reply-To: <e478c91f-28ec-e07a-6afd-0757ac72d1f3@stressinduktion.org>

On 05/18/2016 03:28 PM, Hannes Frederic Sowa wrote:
> On 18.05.2016 15:20, Eric Dumazet wrote:
>> On Wed, 2016-05-18 at 14:14 +0200, Daniel Borkmann wrote:
>>> Start address randomization and blinding in BPF currently use
>>> prandom_u32(). prandom_u32() values are not exposed to unpriviledged
>>> user space to my knowledge, but given other kernel facilities such as
>>> ASLR, stack canaries, etc make use of stronger get_random_int(), we
>>> better make use of it here as well given blinding requests successively
>>> new random values. get_random_int() has minimal entropy pool depletion,
>>> is not cryptographically secure, but doesn't need to be for our use
>>> cases here.
>>
>> Well, if it is not crypto secure, what is the point using it instead of
>> prandom_u32() ?
>
> Leaks of prandom_u32 allows an attacker to find the whole sequence of
> generated random numbers or the other way around.
>
>> I do not think changing this is fundamentally changing something, it
>> looks like code churn or magic incantation to me.
>
> I saw this during the review of the blinding patches. I was afraid, that
> by extracting or dumping the ebpf program, a user could find out the
> blinding constant and after some retries could find out the coefficients
> to the taus rng, thus being able to infer the whole sequence generated
> by prandom_u32.

Note that dumping/extraction is normally not possible: cBPF progs hold the
original insns before they were even transformed into eBPF, and eBPF cannot
be dumped back today, so the rewrites stay kernel internal. Only when an
admin is not careful and accidentally sets things like bpf_jit_enable > 1,
where we have JIT debug mode and the generated image goes to dmesg (I don't
consider this the case normally, but what do I know).

>> There is little amount of entropy since the hole is constrained by
>> PAGE_SIZE.
>
> True.
>
> I don't consider this a big thing, I just mentioned that we probably
> shouldn't use prandom_u32 if the value somehow could leak to user space
> and should be used for security.

Agree here which is why I decided to send it.

Thanks,
Daniel

  reply	other threads:[~2016-05-18 14:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18 12:14 [PATCH net] bpf: rather use get_random_int for randomizations Daniel Borkmann
2016-05-18 13:20 ` Eric Dumazet
2016-05-18 13:28   ` Hannes Frederic Sowa
2016-05-18 14:14     ` Daniel Borkmann [this message]
2016-05-18 14:17     ` Eric Dumazet
2016-05-18 21:18       ` Alexei Starovoitov
2016-05-20 18:24 ` David Miller

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=573C78B8.2050400@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=alexei.starovoitov@gmail.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=hannes@stressinduktion.org \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.