public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Josh Wu <josh.wu@atmel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] tools: gen_eth_addr: remove getpid() operation for the random seed
Date: Wed, 16 Sep 2015 15:08:56 +0800	[thread overview]
Message-ID: <55F91588.3040305@atmel.com> (raw)
In-Reply-To: <20150916063701.44C0C380905@gemini.denx.de>

Hi, Wolfgang

Thanks for the reply.

On 9/16/2015 2:37 PM, Wolfgang Denk wrote:
> Dear Josh Wu,
>
> In message <1442373526-842-1-git-send-email-josh.wu@atmel.com> you wrote:
>> As 'time(0) | getpid()' sometimes get same value. That depends on the
>> value of getpid().
> I think removing some "random input" from the way how we compute the
> seed is a bad idea.
>
>> So that is not a expected behavior. We expect different value for the
>> seed when when run it in many times.
> What is your execution environment? In any sane OS it is higly
> unlikely that you will see the same or even similar PIDs for
> successive runs of the program - each run will start a new process,
> which will get a new PID.
my system is Ubuntu 14.04

#uname -a
Linux melon 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 
2015 x86_64 x86_64 x86_64 GNU/Linux

Following is my test history:

?  tools  date && ./gen_eth_addr
Wed Sep 16 14:48:53 CST 2015
4a:c3:21:45:17:b2
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:48:56 CST 2015
a6:29:4b:0b:e6:d0
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:02 CST 2015
d2:41:66:54:64:aa
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:06 CST 2015
2a:58:1d:b0:f0:c5
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:13 CST 2015
1e:8e:6f:0e:16:b8
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:19 CST 2015
56:4f:58:67:ad:30
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:21 CST 2015
2e:53:29:97:6a:8a
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:26 CST 2015
d2:41:66:54:64:aa
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:35 CST 2015
d2:41:66:54:64:aa

?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:50 CST 2015
92:33:16:3f:0a:56
?  tools  date && ./gen_eth_addr
Wed Sep 16 14:49:58 CST 2015
92:33:16:3f:0a:56

In above commands, I have two duplicated eth addr:
92:33:16:3f:0a:56
d2:41:66:54:64:aa

>
> [On a mostly idle Linux system (4.1.6 kernel) I see zero dupes in a
> set of 30,000 invocations of getpid().]
>
> One can argue if ORing the values is the most clever idea, or if for
> example ADDing them would result in more "randomness".
Sure. The ORing seems has big chance to get same result in my machine.


>   But completely
> removing the pid() is bad - any parallel runs of the program on any
> machines with synchronized times would predictably result in the same
> seeds which is definitely worse behaviour than what we have now.
I understand your concern. My intention is make it harder to generate 
the duplicated result.

Maybe we can ORing the MSB of time(0)?
I'll investigate it little more.

>
>> So this patch remove the getpid(), just use the time(0) as the seed.
> NAK.  This is a bad idea.
>
> Best regards,
>
> Wolfgang Denk
>
Best Regards,
Josh Wu

  reply	other threads:[~2015-09-16  7:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16  3:18 [U-Boot] [PATCH] tools: gen_eth_addr: remove getpid() operation for the random seed Josh Wu
2015-09-16  6:37 ` Wolfgang Denk
2015-09-16  7:08   ` Josh Wu [this message]
2015-09-16  7:27     ` Josh Wu
2015-09-16  9:15     ` Wolfgang Denk
2015-09-16  9:53       ` Josh Wu
2015-09-16  8:23 ` Andreas Bießmann
2015-09-16  9:12   ` Josh Wu
2015-09-16  9:26     ` Andreas Bießmann

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=55F91588.3040305@atmel.com \
    --to=josh.wu@atmel.com \
    --cc=u-boot@lists.denx.de \
    /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