VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: Andrea Arcangeli <aarcange@redhat.com> 2015-09-04 15:47:15 -0700 committer: Linus Torvalds <torvalds@linux-foundation.org> 2015-09-04 16:54:41 -0700 commit: e6485a47b758cae04a496764a1095961ee3249e4 parent: ad465cae96b456b48d26c96f27a0577ba443472a
Commit Summary:
userfaultfd: require UFFDIO_API before other ioctls
Diffstat:
1 file changed, 3 insertions, 1 deletion
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 5f11678907d5..af88ef6fffff 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -577,7 +577,6 @@ static ssize_t userfaultfd_read(struct file *file, char __user *buf,
 
 	if (ctx->state == UFFD_STATE_WAIT_API)
 		return -EINVAL;
-	BUG_ON(ctx->state != UFFD_STATE_RUNNING);
 
 	for (;;) {
 		if (count < sizeof(msg))
@@ -1115,6 +1114,9 @@ static long userfaultfd_ioctl(struct file *file, unsigned cmd,
 	int ret = -EINVAL;
 	struct userfaultfd_ctx *ctx = file->private_data;
 
+	if (cmd != UFFDIO_API && ctx->state == UFFD_STATE_WAIT_API)
+		return -EINVAL;
+
 	switch(cmd) {
 	case UFFDIO_API:
 		ret = userfaultfd_api(ctx, arg);