[PATCH] hw_random core: block read, if !O_NONBLOCK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please apply this to -mm. It might also be desireable
to queue the whole hw_random rewrite for 2.6.18 after this
fix is merged.

--

Block reads to /dev/hwrng if O_NONBLOCK is not set.
This restores the old behavior, to not break userland (rngd).

Thanks to [email protected] for pointing out the issue.

Signed-off-by: Michael Buesch <[email protected]>

Index: hwrng.fixes/drivers/char/hw_random/core.c
===================================================================
--- hwrng.fixes.orig/drivers/char/hw_random/core.c	2006-05-16 21:52:47.000000000 +0200
+++ hwrng.fixes/drivers/char/hw_random/core.c	2006-05-27 00:39:08.000000000 +0200
@@ -125,7 +125,7 @@
 		mutex_unlock(&rng_mutex);
 
 		err = -EAGAIN;
-		if (!bytes_read)
+		if (!bytes_read && (filp->f_flags & O_NONBLOCK))
 			goto out;
 
 		err = -EFAULT;
@@ -138,6 +138,9 @@
 			data >>= 8;
 		}
 
+		if (need_resched())
+			schedule_timeout_interruptible(1);
+		err = -ERESTARTSYS;
 		if (signal_pending(current))
 			goto out;
 	}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux