Applied assortment of Arch Linux ARM patches
This commit is contained in:
@@ -265,6 +265,9 @@
|
||||
#include <asm/irq.h>
|
||||
#include <asm/irq_regs.h>
|
||||
#include <asm/io.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/completion.h>
|
||||
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/random.h>
|
||||
@@ -397,6 +400,7 @@ static struct poolinfo {
|
||||
*/
|
||||
static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
|
||||
static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
|
||||
static DECLARE_WAIT_QUEUE_HEAD(urandom_init_wait);
|
||||
static struct fasync_struct *fasync;
|
||||
|
||||
static bool debug;
|
||||
@@ -606,8 +610,11 @@ retry:
|
||||
|
||||
if (!r->initialized && nbits > 0) {
|
||||
r->entropy_total += nbits;
|
||||
if (r->entropy_total > 128)
|
||||
if (r->entropy_total > 128) {
|
||||
r->initialized = 1;
|
||||
if (r == &nonblocking_pool)
|
||||
prandom_reseed_late();
|
||||
}
|
||||
}
|
||||
|
||||
trace_credit_entropy_bits(r->name, nbits, entropy_count,
|
||||
@@ -1015,13 +1022,14 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
|
||||
{
|
||||
ssize_t ret = 0, i;
|
||||
__u8 tmp[EXTRACT_SIZE];
|
||||
int large_request = (nbytes > 256);
|
||||
|
||||
trace_extract_entropy_user(r->name, nbytes, r->entropy_count, _RET_IP_);
|
||||
xfer_secondary_pool(r, nbytes);
|
||||
nbytes = account(r, nbytes, 0, 0);
|
||||
|
||||
while (nbytes) {
|
||||
if (need_resched()) {
|
||||
if (large_request && need_resched()) {
|
||||
if (signal_pending(current)) {
|
||||
if (ret == 0)
|
||||
ret = -ERESTARTSYS;
|
||||
@@ -1155,8 +1163,7 @@ void rand_initialize_disk(struct gendisk *disk)
|
||||
#endif
|
||||
|
||||
static ssize_t
|
||||
random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
_random_read(int nonblock, char __user *buf, size_t nbytes){
|
||||
ssize_t n, retval = 0, count = 0;
|
||||
|
||||
if (nbytes == 0)
|
||||
@@ -1180,7 +1187,7 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
n*8, (nbytes-n)*8);
|
||||
|
||||
if (n == 0) {
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
if (nonblock) {
|
||||
retval = -EAGAIN;
|
||||
break;
|
||||
}
|
||||
@@ -1211,6 +1218,12 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
return (count ? count : retval);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
return _random_read(file->f_flags & O_NONBLOCK, buf, nbytes);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
@@ -1337,6 +1350,29 @@ const struct file_operations urandom_fops = {
|
||||
.llseek = noop_llseek,
|
||||
};
|
||||
|
||||
SYSCALL_DEFINE3(getrandom, char __user *, buf, size_t, count,
|
||||
unsigned int, flags)
|
||||
{
|
||||
if (flags & ~(GRND_NONBLOCK|GRND_RANDOM))
|
||||
return -EINVAL;
|
||||
|
||||
if (count > INT_MAX)
|
||||
count = INT_MAX;
|
||||
|
||||
if (flags & GRND_RANDOM)
|
||||
return _random_read(flags & GRND_NONBLOCK, buf, count);
|
||||
|
||||
if (unlikely(nonblocking_pool.initialized == 0)) {
|
||||
if (flags & GRND_NONBLOCK)
|
||||
return -EAGAIN;
|
||||
wait_event_interruptible(urandom_init_wait,
|
||||
nonblocking_pool.initialized);
|
||||
if (signal_pending(current))
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
return urandom_read(NULL, buf, count, NULL);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* Random UUID interface
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user