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.

Input: evdev - call input_flush_device() on release(), not flush()

input_flush_device() should only be called once the struct file is being
released and no open descriptors remain, but evdev_flush() was calling
it whenever a file descriptor was closed.

This caused uploaded force-feedback effects to be erased when a process
did a dup()/close() on the event FD, called system(), etc.

Call input_flush_device() from evdev_release() instead.

Reported-by: Mathieu Maret <mathieu.maret@gmail.com>
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Link: https://lore.kernel.org/r/20200421231003.7935-1-bshanks@codeweavers.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Brendan Shanks and committed by
Dmitry Torokhov
09264098 18931506

+4 -15
+4 -15
drivers/input/evdev.c
··· 326 326 return fasync_helper(fd, file, on, &client->fasync); 327 327 } 328 328 329 - static int evdev_flush(struct file *file, fl_owner_t id) 330 - { 331 - struct evdev_client *client = file->private_data; 332 - struct evdev *evdev = client->evdev; 333 - 334 - mutex_lock(&evdev->mutex); 335 - 336 - if (evdev->exist && !client->revoked) 337 - input_flush_device(&evdev->handle, file); 338 - 339 - mutex_unlock(&evdev->mutex); 340 - return 0; 341 - } 342 - 343 329 static void evdev_free(struct device *dev) 344 330 { 345 331 struct evdev *evdev = container_of(dev, struct evdev, dev); ··· 439 453 unsigned int i; 440 454 441 455 mutex_lock(&evdev->mutex); 456 + 457 + if (evdev->exist && !client->revoked) 458 + input_flush_device(&evdev->handle, file); 459 + 442 460 evdev_ungrab(evdev, client); 443 461 mutex_unlock(&evdev->mutex); 444 462 ··· 1300 1310 .compat_ioctl = evdev_ioctl_compat, 1301 1311 #endif 1302 1312 .fasync = evdev_fasync, 1303 - .flush = evdev_flush, 1304 1313 .llseek = no_llseek, 1305 1314 }; 1306 1315