public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
To: "Kohli, Gaurav" <gkohli@codeaurora.org>
Cc: jslaby@suse.com, gregkh@linuxfoundation.org, mikey@neuling.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH] tty: fix data race in n_tty_receive_buf_common
Date: Fri, 5 Jan 2018 13:36:09 +0000	[thread overview]
Message-ID: <20180105133609.636b2d1f@alans-desktop> (raw)
In-Reply-To: <999c5499-05c7-4702-77a7-dfb56ba577d2@codeaurora.org>

On Fri, 5 Jan 2018 13:15:45 +0530
"Kohli, Gaurav" <gkohli@codeaurora.org> wrote:

> Hi Alan,
> >>>
> >>> Can you make that code available otherwise it's impossible to see 
> >>> what the problem might be.  
> >
> >  
>   https://source.codeaurora.org/quic/la/kernel/msm-4.9/tree/drivers/tty/serial?h=msm-4.9
>   As discussed , there not seems a problem as we are getting print 
> request even when port seems to closed.
> 
> 
> tty_ldisc_lock(tty, 5 * HZ);
>   tty_ldisc_setup(tty);
>   tty_ldisc_unlock(tty)
> 
> But in above lock,  there is a chance when flush_to_ldisc will occur 
> first and acquired a lock in
> tty_ldisc_ref itself.

Which is fine.

If the flush_to_ldisc gets there first then it will find there is a NULL
ldisc and do nothing. When it finishes the tty_init_dev will run and will
be protected from a further re-entry.

If the init_dev gets there first it will complete the init before the
flush_to_ldisc is permitted to proceed.

In other words we restore the intended invariant that ldisc's do not get
entered while their setup routine is running.

Alan

  reply	other threads:[~2018-01-05 13:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03 13:48 [PATCH] tty: fix data race in n_tty_receive_buf_common Gaurav Kohli
2018-01-03 19:38 ` Alan Cox
2018-01-04  5:47   ` Kohli, Gaurav
2018-01-04 11:09     ` Alan Cox
2018-01-04 13:46       ` Kohli, Gaurav
2018-01-04 14:37         ` Alan Cox
2018-01-05  7:34           ` Kohli, Gaurav
2018-01-05  7:45             ` Kohli, Gaurav
2018-01-05 13:36               ` Alan Cox [this message]
2018-01-05 13:56                 ` Kohli, Gaurav
2018-01-05 14:15                   ` Alan Cox
2018-01-05 20:14                     ` Kohli, Gaurav
2018-01-05 20:24                       ` Kohli, Gaurav
2018-01-05 21:05                         ` Alan Cox
2018-01-06  7:50                           ` Kohli, Gaurav
2018-01-17 13:25                             ` Kohli, Gaurav
2018-01-20 18:49                               ` Alan Cox
2018-01-05 20:28                       ` Kohli, Gaurav

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=20180105133609.636b2d1f@alans-desktop \
    --to=gnomes@lxorguk.ukuu.org.uk \
    --cc=gkohli@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikey@neuling.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox