From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Sean Hunter <sean@dev.sportingbet.com>
Cc: Matt Johnston <mlkm@caifex.org>,
Linux Kernel Development <linux-kernel@vger.kernel.org>
Subject: Re: random PID generation
Date: Fri, 23 Feb 2001 12:50:38 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.3.95.1010223123332.3967A-100000@chaos.analogic.com> (raw)
In-Reply-To: <20010223171440.K10620@dev.sportingbet.com>
On Fri, 23 Feb 2001, Sean Hunter wrote:
> I have already written a 2.2 implementation which does not suffer from these
> problems. It was rejected because Alan Cox (and others) felt it only provided
> security through obscurity.
>
> Sean
The following is a simple random generator that will never give two
consecutive like numbers (therefore it's not really random). It's
pretty good for things like non-guessible PIDs, TCP/IP ports, etc.
Just mask off the length that you don't need. It this was called
occasionally from some timer or other interrupt, you don't even know its
starting value. With the current magic number, it's period is 0xfffnnnnn.
Several years ago, I ran an exhaustive search program (133MHz CPU) looking
for a magic number to produce a longer period. I'm told that there
is a magic number that will give a period of 0xffffffff.
static int rnn = 0;
static int rnd()
{
int ret;
__asm__ __volatile__(
"\tmovl (rnn), %%eax\n"
"\trorl $3, %%eax\n"
"\taddl $0x586c3ec3, %%eax\n"
"\tmovl %%eax, (rnn)\n"
: "=eax" (ret) );
return ret;
}
Cheers,
Dick Johnson
Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).
"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.
next prev parent reply other threads:[~2001-02-23 17:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-23 15:34 random PID generation Heusden, Folkert van
2001-02-23 15:40 ` Matt Johnston
2001-02-23 17:14 ` Sean Hunter
2001-02-23 17:50 ` Richard B. Johnson [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-02-27 10:35 Heusden, Folkert van
2001-02-23 13:20 Heusden, Folkert van
2001-02-23 14:18 ` bert hubert
2001-02-22 15:35 Heusden, Folkert van
2001-02-22 22:24 ` bert hubert
2001-02-22 21:42 ` H. Peter Anvin
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=Pine.LNX.3.95.1010223123332.3967A-100000@chaos.analogic.com \
--to=root@chaos.analogic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mlkm@caifex.org \
--cc=sean@dev.sportingbet.com \
/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;
as well as URLs for NNTP newsgroup(s).