Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751351AbdGQMbw (ORCPT ); Mon, 17 Jul 2017 08:31:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45982 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751281AbdGQMbu (ORCPT ); Mon, 17 Jul 2017 08:31:50 -0400 Date: Mon, 17 Jul 2017 14:31:45 +0200 From: Greg Kroah-Hartman To: Okash Khawaja Cc: Alan Cox , Jiri Slaby , Samuel Thibault , linux-kernel@vger.kernel.org, William Hubbs , Chris Brannon , Kirk Reiser , speakup@linux-speakup.org, devel@driverdev.osuosl.org Subject: Re: [patch 0/3] Re: tty contention resulting from tty_open_by_device export Message-ID: <20170717123145.GE24503@kroah.com> References: <20170708083803.GA23080@kroah.com> <20170709114153.157783481@gmail.com> <20170710125233.2006733e@alans-desktop> <20170710123307.GA777@sanghar> <20170712192028.70bc0d54@alans-desktop> <20170713112954.GA665@sanghar> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170713112954.GA665@sanghar> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1191 Lines: 27 On Thu, Jul 13, 2017 at 12:29:54PM +0100, Okash Khawaja wrote: > On Wed, Jul 12, 2017 at 07:20:28PM +0100, Alan Cox wrote: > > > > > When opening from kernel, we don't use file pointer. The count mismatch > > > is between tty->count and #fd's. So opening from kernel leads to #fd's > > > being less than tty->count. I thought this difference is relevant to > > > user-space opening of tty, and not to kernel opening of tty. Can you > > > suggest how to address this mismatch? > > > > Your kernel reference is the same as having a file open reference so I > > think this actually needs addressing in the maths. In other words count > > the number of kernel references and also add that into the test for > > check_tty_count (kernel references + #fds == count). > > > > I'd really like to keep this right because that check has a long history > > of catching really nasty race conditions in the tty code. The > > open/close/hangup code is really fragile so worth the debugability. > > I see. Okay based this, check_tty_count can be easily updated to take > into account kernel references. Ok, I'll drop this series from my "to-apply" queue and wait for you to redo it. thanks, greg k-h