mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* random ioctls - are they supposed to be like this?
@ 2004-08-18 20:42 Bill Nottingham
  0 siblings, 0 replies; only message in thread
From: Bill Nottingham @ 2004-08-18 20:42 UTC (permalink / raw)
  To: linux-kernel

include/linux/random.h has:

#define RNDADDENTROPY   _IOW( 'R', 0x03, int [2] )
#define RNDGETPOOL      _IOR( 'R', 0x02, int [2] )

However, these seem to be used differently in practice.
For example, the one user of RNDADDENTROPY I find does:

struct {
	int ent_count;
	int size;
	unsigned char data[size];
} entropy;

if (ioctl(fd, RNDADDENTROPY, &entropy) != 0) {
...

And, looking at the random driver, it does appear to expect
this format.

Now, RNDGETPOOL in the kernel does:

if (get_user(size, p) ||
    put_user(random_state->poolinfo.poolwords, p++))
	return -EFAULT;
...
if (!copy_to_user(p, tmp, size * sizeof(__u32))) {
...
if(put_user(ent_count, p++))
	return -EFAULT;

Which obviously isn't going to work right if you
just pass in a two-int structure.

Am I reading this wrong, or are callers just supposed
to know to use the other interface?

Bill

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-18 20:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-18 20:42 random ioctls - are they supposed to be like this? Bill Nottingham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®