From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbdGQNXu (ORCPT ); Mon, 17 Jul 2017 09:23:50 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33133 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751281AbdGQNXs (ORCPT ); Mon, 17 Jul 2017 09:23:48 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [patch 0/3] Re: tty contention resulting from tty_open_by_device export From: Okash Khawaja X-Mailer: iPhone Mail (11A501) In-Reply-To: <20170717123145.GE24503@kroah.com> Date: Mon, 17 Jul 2017 14:23:46 +0100 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" Message-Id: <3E107A3D-D8E2-43E5-8DCB-F9DE2F5AAAEA@gmail.com> References: <20170708083803.GA23080@kroah.com> <20170709114153.157783481@gmail.com> <20170710125233.2006733e@alans-desktop> <20170710123307.GA777@sanghar> <20170712192028.70bc0d54@alans-desktop> <20170713112954.GA665@sanghar> <20170717123145.GE24503@kroah.com> To: Greg Kroah-Hartman Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v6HDNu21009695 > On 17 Jul 2017, at 13:31, Greg Kroah-Hartman wrote: > >> 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. Sure. I can fix the tty->count mismatch based on Alan's suggestion. However I don't understand why the exclusivity flag should belong to tty_port and not tty_struct. It will be good to know why. Thanks, Okash