Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp690531ybg; Mon, 1 Jun 2020 11:46:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFwyqf0Q0Xv7K7Gyv7W3Z2GyGJf076AY1C3/dPvJwFV5op05gKe1tnFMBFSJmy5vcYxhtF X-Received: by 2002:a17:906:1f8b:: with SMTP id t11mr20644487ejr.201.1591037218280; Mon, 01 Jun 2020 11:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591037218; cv=none; d=google.com; s=arc-20160816; b=acft9z00OtzcJl+zHNbwOecS7dA00zyMQucmGxzPL88bnlLSvyalaF6XPWVQbBkCfG T2d4iQRCb8IDmIySMYbuoNyAGg6JJibN/RsjHP6UUOt6pF5BcQkz+xcN9Cd023EyE4bN li0zXz2/4L/R874RSbtOuMXyQ4ihyXIPDgHLcyMemrDxlAbrjF/Unjddb3KMJ8oA4EZM VQjvzCi2WnYGrwqJU/DtcW816+o+hpwkrwHz16+TBO3RBigDXOJjp+dNpZGZ8Pm0zFv7 HRbswG45/dn5RA/DhAbx9fJmYvb1oxo9BaZAVGpXZRcnRabsbYUGphWO1Ed5vd3/Dz4S N9/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8CLeL7q543knlJ2mkrdviQDHO9y3BO2h8zHiSeKaj9o=; b=GlB/F5y2ZlpzH+wyJ5hcc7+EZseb2Fc70vSwOSHeuGI44I4CaHJWrRgjUCqSoz7ech oNd/8vKcTSUrdQKKJgBuI5q88nexHsw+DK4mq+SX0Q+G9bW2m6Wuq0nVrW4A1C/cDd+D 5TaTjqnz+3F69NRSIuWJSDzbjImqPuP0mjdyCx8PRoZQF9SlODU7OxAeBbM8jI+73axL LOKxPd1oQIfF+P0+EgbsRewSEWtAyWBm2ycpmFRLp5KofATofBNwJsZVVkggOQBaMpCE r30Kic1qGuyVKhdIL3nEaZAnmXuHQAr6A6LMEFM9KP63HBXxyELwbflAgIqZC9zao281 oOBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TkRS+VKr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si178665ejq.486.2020.06.01.11.46.35; Mon, 01 Jun 2020 11:46:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TkRS+VKr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730052AbgFASKJ (ORCPT + 99 others); Mon, 1 Jun 2020 14:10:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730945AbgFASJ4 (ORCPT ); Mon, 1 Jun 2020 14:09:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBEC720872; Mon, 1 Jun 2020 18:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034995; bh=eh0C+0x9mVrpmssuTcn3nRjVa4S+T2umUEJ6R35Nwt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TkRS+VKrcq54r6POyT5IfRVcLUIbe8apYsMs5Y0GDRNn2dYYRObAYWa9VVZpwo8je 70IlTjH/cz80PsPlw/quJGZJQO3BsGaLxqwZT38aZf5U/yK1OL37Cs+atZnIG4zIxC FwmeMorbQ5h9P2fSEGFmqhjrUMsALqPaPDf3+FS0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathieu Maret , Brendan Shanks , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.4 065/142] Input: evdev - call input_flush_device() on release(), not flush() Date: Mon, 1 Jun 2020 19:53:43 +0200 Message-Id: <20200601174044.622686044@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174037.904070960@linuxfoundation.org> References: <20200601174037.904070960@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brendan Shanks [ Upstream commit 09264098ff153f60866039d60b31d39b66f55a31 ] 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 Signed-off-by: Brendan Shanks Link: https://lore.kernel.org/r/20200421231003.7935-1-bshanks@codeweavers.com Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/evdev.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index cb6e3a5f509c..0d57e51b8ba1 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -326,20 +326,6 @@ static int evdev_fasync(int fd, struct file *file, int on) return fasync_helper(fd, file, on, &client->fasync); } -static int evdev_flush(struct file *file, fl_owner_t id) -{ - struct evdev_client *client = file->private_data; - struct evdev *evdev = client->evdev; - - mutex_lock(&evdev->mutex); - - if (evdev->exist && !client->revoked) - input_flush_device(&evdev->handle, file); - - mutex_unlock(&evdev->mutex); - return 0; -} - static void evdev_free(struct device *dev) { struct evdev *evdev = container_of(dev, struct evdev, dev); @@ -453,6 +439,10 @@ static int evdev_release(struct inode *inode, struct file *file) unsigned int i; mutex_lock(&evdev->mutex); + + if (evdev->exist && !client->revoked) + input_flush_device(&evdev->handle, file); + evdev_ungrab(evdev, client); mutex_unlock(&evdev->mutex); @@ -1310,7 +1300,6 @@ static const struct file_operations evdev_fops = { .compat_ioctl = evdev_ioctl_compat, #endif .fasync = evdev_fasync, - .flush = evdev_flush, .llseek = no_llseek, }; -- 2.25.1