[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180105133609.636b2d1f@alans-desktop>
Date: Fri, 5 Jan 2018 13:36:09 +0000
From: Alan Cox <gnomes@...rguk.ukuu.org.uk>
To: "Kohli, Gaurav" <gkohli@...eaurora.org>
Cc: jslaby@...e.com, gregkh@...uxfoundation.org, mikey@...ling.org,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH] tty: fix data race in n_tty_receive_buf_common
On Fri, 5 Jan 2018 13:15:45 +0530
"Kohli, Gaurav" <gkohli@...eaurora.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
Powered by blists - more mailing lists