All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>, linux-input@vger.kernel.org
Subject: [PATCH] Input: evdev - Use EBADFD for flush() errors
Date: Wed, 19 Aug 2015 09:38:15 +0200	[thread overview]
Message-ID: <1439969895-26163-1-git-send-email-tiwai@suse.de> (raw)

We've got bug reports showing the old systemd-logind (at least
system-210) aborting unexpectedly, and this turned out to be because
of an invalid error code from close() call to evdev devices.  close()
is supposed to return only either EINTR or EBADFD, while the device
returned ENODEV.  logind was overreacting to it and decided to kill
itself when an unexpected error code was received.  What a tragedy.

The bad error code comes from flush fops, and actually evdev_flush()
returns -ENODEV and else.  This patch papers over it, simply fixing
the error return code to the acceptable values above.

Bugzilla: http://bugzilla.suse.com/show_bug.cgi?id=939834
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/input/evdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 9d35499faca4..28e9efd837e1 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -302,7 +302,7 @@ static int evdev_flush(struct file *file, fl_owner_t id)
 		retval = input_flush_device(&evdev->handle, file);
 
 	mutex_unlock(&evdev->mutex);
-	return retval;
+	return retval < 0 ? -EBADFD : 0;
 }
 
 static void evdev_free(struct device *dev)
-- 
2.5.0


             reply	other threads:[~2015-08-19  7:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19  7:38 Takashi Iwai [this message]
2015-09-01  5:23 ` [PATCH] Input: evdev - Use EBADFD for flush() errors Takashi Iwai
2015-09-04  5:37   ` Dmitry Torokhov
2015-09-04  5:42     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439969895-26163-1-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.