Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input update from Dmitry Torokhov:
"The only change is David Hermann's new EVIOCREVOKE evdev ioctl that
allows safely passing file descriptors to input devices to session
processes and later being able to stop delivery of events through
these fds so that inactive sessions will no longer receive user input
that does not belong to them"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: evdev - add EVIOCREVOKE ioctl

+32 -6
+31 -6
drivers/input/evdev.c
··· 48 48 struct evdev *evdev; 49 49 struct list_head node; 50 50 int clkid; 51 + bool revoked; 51 52 unsigned int bufsize; 52 53 struct input_event buffer[]; 53 54 }; ··· 165 164 struct input_event event; 166 165 bool wakeup = false; 167 166 167 + if (client->revoked) 168 + return; 169 + 168 170 event.time = ktime_to_timeval(client->clkid == CLOCK_MONOTONIC ? 169 171 mono : real); 170 172 ··· 244 240 if (retval) 245 241 return retval; 246 242 247 - if (!evdev->exist) 243 + if (!evdev->exist || client->revoked) 248 244 retval = -ENODEV; 249 245 else 250 246 retval = input_flush_device(&evdev->handle, file); ··· 433 429 if (retval) 434 430 return retval; 435 431 436 - if (!evdev->exist) { 432 + if (!evdev->exist || client->revoked) { 437 433 retval = -ENODEV; 438 434 goto out; 439 435 } ··· 486 482 return -EINVAL; 487 483 488 484 for (;;) { 489 - if (!evdev->exist) 485 + if (!evdev->exist || client->revoked) 490 486 return -ENODEV; 491 487 492 488 if (client->packet_head == client->tail && ··· 515 511 if (!(file->f_flags & O_NONBLOCK)) { 516 512 error = wait_event_interruptible(evdev->wait, 517 513 client->packet_head != client->tail || 518 - !evdev->exist); 514 + !evdev->exist || client->revoked); 519 515 if (error) 520 516 return error; 521 517 } ··· 533 529 534 530 poll_wait(file, &evdev->wait, wait); 535 531 536 - mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; 532 + if (evdev->exist && !client->revoked) 533 + mask = POLLOUT | POLLWRNORM; 534 + else 535 + mask = POLLHUP | POLLERR; 536 + 537 537 if (client->packet_head != client->tail) 538 538 mask |= POLLIN | POLLRDNORM; 539 539 ··· 803 795 return 0; 804 796 } 805 797 798 + static int evdev_revoke(struct evdev *evdev, struct evdev_client *client, 799 + struct file *file) 800 + { 801 + client->revoked = true; 802 + evdev_ungrab(evdev, client); 803 + input_flush_device(&evdev->handle, file); 804 + wake_up_interruptible(&evdev->wait); 805 + 806 + return 0; 807 + } 808 + 806 809 static long evdev_do_ioctl(struct file *file, unsigned int cmd, 807 810 void __user *p, int compat_mode) 808 811 { ··· 875 856 return evdev_grab(evdev, client); 876 857 else 877 858 return evdev_ungrab(evdev, client); 859 + 860 + case EVIOCREVOKE: 861 + if (p) 862 + return -EINVAL; 863 + else 864 + return evdev_revoke(evdev, client, file); 878 865 879 866 case EVIOCSCLOCKID: 880 867 if (copy_from_user(&i, p, sizeof(unsigned int))) ··· 1027 1002 if (retval) 1028 1003 return retval; 1029 1004 1030 - if (!evdev->exist) { 1005 + if (!evdev->exist || client->revoked) { 1031 1006 retval = -ENODEV; 1032 1007 goto out; 1033 1008 }
+1
include/uapi/linux/input.h
··· 152 152 #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ 153 153 154 154 #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 155 + #define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */ 155 156 156 157 #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ 157 158