From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753450AbbG3Nx0 (ORCPT ); Thu, 30 Jul 2015 09:53:26 -0400 Received: from mx2.suse.de ([195.135.220.15]:34818 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbbG3NxX (ORCPT ); Thu, 30 Jul 2015 09:53:23 -0400 Date: Thu, 30 Jul 2015 15:53:20 +0200 Message-ID: From: Takashi Iwai To: Dmitry Torokhov Cc: Al Viro , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, "Dr. Werner Fink" Subject: Re: May close() return any error code? In-Reply-To: <20150729144511.GA11233@dtor-ws> References: <20150729144511.GA11233@dtor-ws> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.5 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Jul 2015 16:45:11 +0200, Dmitry Torokhov wrote: > > HI Takashi, > > On Wed, Jul 29, 2015 at 12:46:59PM +0200, Takashi Iwai wrote: > > Hi, > > > > while debugging a problem of X and gdm with the old systemd-210, we > > encountered a sudden death of systemd-logind, and this turned out to > > be an unexpected errno from close(). The close() call for input > > devices returns ENODEV error. The logind in systemd-210 treats this > > error code as fatal, triggers assert() and eventually kills itself. > > The details are found in an openSUSE bugzilla thread: > > https://bugzilla.opensuse.org/show_bug.cgi?id=939571 > > > > This seems coming from evdev_flush(). As there is no fd leak, it's no > > big problem per se. But, now the question is whether returning such > > an error code is correct behavior at all. At least, it doesn't seem > > defined in POSIX: > > http://pubs.opengroup.org/onlinepubs/009695399/functions/close.html > > Hmm, if I checked the right version of the code close_nointr_nofail() > expects only 0 as the return code so even if we change the kernel to > use more conforming -EIO instead of -ENODEV systemd will still die... Yes, it can be seen rather as a bug in systemd-210, and the later systemd version doesn't seem to trigger assert() with that condition. > The question is whether we really need to propagate return value from > f_op->flush() up to userspace in filp_close(). Why don't we ask Al? Oh yes, of course, Al is the best person to ask :) Looking back at this problem now, I find it even dangerous to propagate an error, especially -EINTR. Then user-space may interpret it as if the close didn't succeed and the fd were alive, although the kernel performed the close itself. thanks, Takashi