public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 4/22] /dev/random: remove outdated RNDGETPOOL ioctl
Date: Thu, 25 Mar 2004 17:57:42 -0600	[thread overview]
Message-ID: <5.524465763@selenic.com> (raw)
In-Reply-To: <4.524465763@selenic.com>


/dev/random  remove outdated RNDGETPOOL ioctl

Remove RNDGETPOOL ioctl, which has outlived its usefulness for
debugging as it only atomically captures the state of one pool.
There's no other value (except to attackers) of direct access to the
input pool from userspace.


 tiny-mpm/drivers/char/random.c        |   40 +---------------------------------
 tiny-mpm/include/linux/compat_ioctl.h |    1 
 tiny-mpm/include/linux/random.h       |    5 ----
 3 files changed, 3 insertions(+), 43 deletions(-)

diff -puN drivers/char/random.c~kill-getstate drivers/char/random.c
--- tiny/drivers/char/random.c~kill-getstate	2004-03-20 13:38:12.000000000 -0600
+++ tiny-mpm/drivers/char/random.c	2004-03-20 13:38:12.000000000 -0600
@@ -1671,10 +1671,9 @@ static int
 random_ioctl(struct inode * inode, struct file * file,
 	     unsigned int cmd, unsigned long arg)
 {
-	int *p, *tmp, size, ent_count;
+	int *p, size, ent_count;
 	int retval;
-	unsigned long flags;
-	
+
 	switch (cmd) {
 	case RNDGETENTCNT:
 		ent_count = random_state->entropy_count;
@@ -1694,41 +1693,6 @@ random_ioctl(struct inode * inode, struc
 		if (random_state->entropy_count >= random_read_wakeup_thresh)
 			wake_up_interruptible(&random_read_wait);
 		return 0;
-	case RNDGETPOOL:
-		if (!capable(CAP_SYS_ADMIN))
-			return -EPERM;
-		p = (int *) arg;
-		if (get_user(size, p) ||
-		    put_user(random_state->poolinfo.poolwords, p++))
-			return -EFAULT;
-		if (size < 0)
-			return -EFAULT;
-		if (size > random_state->poolinfo.poolwords)
-			size = random_state->poolinfo.poolwords;
-
-		/* prepare to atomically snapshot pool */
-
-		tmp = kmalloc(size * sizeof(__u32), GFP_KERNEL);
-
-		if (!tmp)
-			return -ENOMEM;
-
-		spin_lock_irqsave(&random_state->lock, flags);
-		ent_count = random_state->entropy_count;
-		memcpy(tmp, random_state->pool, size * sizeof(__u32));
-		spin_unlock_irqrestore(&random_state->lock, flags);
-
-		if (!copy_to_user(p, tmp, size * sizeof(__u32))) {
-			kfree(tmp);
-			return -EFAULT;
-		}
-
-		kfree(tmp);
-
-		if(put_user(ent_count, p++))
-			return -EFAULT;
-
-		return 0;
 	case RNDADDENTROPY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
diff -puN include/linux/compat_ioctl.h~kill-getstate include/linux/compat_ioctl.h
--- tiny/include/linux/compat_ioctl.h~kill-getstate	2004-03-20 13:38:12.000000000 -0600
+++ tiny-mpm/include/linux/compat_ioctl.h	2004-03-20 13:38:12.000000000 -0600
@@ -584,7 +584,6 @@ COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
 /* Big R */
 COMPATIBLE_IOCTL(RNDGETENTCNT)
 COMPATIBLE_IOCTL(RNDADDTOENTCNT)
-COMPATIBLE_IOCTL(RNDGETPOOL)
 COMPATIBLE_IOCTL(RNDADDENTROPY)
 COMPATIBLE_IOCTL(RNDZAPENTCNT)
 COMPATIBLE_IOCTL(RNDCLEARPOOL)
diff -puN include/linux/random.h~kill-getstate include/linux/random.h
--- tiny/include/linux/random.h~kill-getstate	2004-03-20 13:38:12.000000000 -0600
+++ tiny-mpm/include/linux/random.h	2004-03-20 13:38:12.000000000 -0600
@@ -17,10 +17,7 @@
 /* Add to (or subtract from) the entropy count.  (Superuser only.) */
 #define RNDADDTOENTCNT	_IOW( 'R', 0x01, int )
 
-/* Get the contents of the entropy pool.  (Superuser only.) */
-#define RNDGETPOOL	_IOR( 'R', 0x02, int [2] )
-
-/* 
+/*
  * Write bytes into the entropy pool and add to the entropy count.
  * (Superuser only.)
  */

_

  reply	other threads:[~2004-03-25 23:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-25 23:57 [PATCH 0/22] /dev/random: Assorted fixes and cleanups Matt Mackall
2004-03-25 23:57 ` [PATCH 1/22] /dev/random: Simplify entropy debugging Matt Mackall
2004-03-25 23:57   ` [PATCH 2/22] /dev/random: Cleanup sleep logic Matt Mackall
2004-03-25 23:57     ` [PATCH 3/22] /dev/random: remove broken resizing sysctl Matt Mackall
2004-03-25 23:57       ` Matt Mackall [this message]
2004-03-25 23:57         ` [PATCH 5/22] /dev/random: pool struct cleanup and rename Matt Mackall
2004-03-25 23:57           ` [PATCH 6/22] /dev/random: simplify pool initialization Matt Mackall
2004-03-25 23:57             ` [PATCH 7/22] /dev/random: simplify reseed logic Matt Mackall
2004-03-25 23:57               ` [PATCH 8/22] /dev/random: BUG on premature random users Matt Mackall
2004-03-25 23:57                 ` [PATCH 9/22] /dev/random: more robust catastrophic reseed logic Matt Mackall
2004-03-25 23:57                   ` [PATCH 10/22] /dev/random: entropy reserve logic for starvation preve Matt Mackall
2004-03-25 23:57                     ` [PATCH 11/22] /dev/random: flag pools that need entropy reserve Matt Mackall
2004-03-25 23:57                       ` [PATCH 12/22] /dev/random: add pool for /dev/urandom to prevent starv Matt Mackall
2004-03-25 23:57                         ` [PATCH 13/22] /dev/random: kill extract_timer_state Matt Mackall
2004-03-25 23:57                           ` [PATCH 14/22] /dev/random: kill unused md5 copy Matt Mackall
2004-03-25 23:57                             ` [PATCH 15/22] /dev/random: kill unrolled SHA code Matt Mackall
2004-03-25 23:57                               ` [PATCH 16/22] /dev/random: kill 2.2 cruft Matt Mackall
2004-03-25 23:57                                 ` [PATCH 17/22] /dev/random: minor shrinkage Matt Mackall
2004-03-25 23:57                                   ` [PATCH 18/22] /dev/random: bitop cleanup Matt Mackall
2004-03-25 23:57                                     ` [PATCH 19/22] /dev/random: use sched_clock for timing data Matt Mackall
2004-03-25 23:57                                       ` [PATCH 20/22] /dev/random: cleanup rol bitop Matt Mackall
2004-03-25 23:57                                         ` [PATCH 21/22] /dev/random: kill batching of entropy mixing Matt Mackall
2004-03-25 23:57                                           ` [PATCH 22/22] /dev/random: update credits Matt Mackall
2004-03-27 13:52                                           ` [PATCH 21/22] /dev/random: kill batching of entropy mixing Jamie Lokier
2004-03-27 15:17                                             ` Matt Mackall
2004-03-26  1:43                               ` [PATCH 15/22] /dev/random: kill unrolled SHA code Jeff Garzik
2004-03-26  3:59                                 ` Matt Mackall
2004-03-27 13:49                                   ` Jamie Lokier
2004-03-26  0:15         ` [PATCH 4/22] /dev/random: remove outdated RNDGETPOOL ioctl Andrew Morton
2004-03-26  0:15       ` [PATCH 3/22] /dev/random: remove broken resizing sysctl Andrew Morton
2004-03-26  3:53         ` Matt Mackall
2004-03-26  0:14     ` [PATCH 2/22] /dev/random: Cleanup sleep logic Andrew Morton
2004-03-26  3:49       ` Matt Mackall

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=5.524465763@selenic.com \
    --to=mpm@selenic.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox