From: Saubhik Mukherjee <saubhik.mukherjee@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>,
jirislaby@kernel.org, linux-serial@vger.kernel.org,
linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org,
andrianov@ispras.ru
Subject: Re: [PATCH] tty: serial: owl: Fix data race in owl_uart_remove
Date: Fri, 25 Jun 2021 13:22:11 +0530 [thread overview]
Message-ID: <ff208383-aefa-17d0-891c-ee5a10edd1fe@gmail.com> (raw)
In-Reply-To: <YNR6uEbCJOa9s3hG@hovoldconsulting.com>
On 6/24/21 5:59 PM, Johan Hovold wrote:
> On Thu, Jun 24, 2021 at 05:37:38PM +0530, Saubhik Mukherjee wrote:
>> On 6/23/21 12:46 PM, Johan Hovold wrote:
>>> On Wed, Jun 23, 2021 at 11:06:53AM +0530, Saubhik Mukherjee wrote:
>>>> On 6/17/21 4:52 PM, Greg KH wrote:
>>>>> On Thu, Jun 17, 2021 at 04:34:43PM +0530, Saubhik Mukherjee wrote:
>>>>>> Suppose the driver is registered and a UART port is added. Once an
>>>>>> application opens the port, owl_uart_startup is called which registers
>>>>>> the interrupt handler owl_uart_irq.
>>>>>>
>>>>>> We could have the following race condition:
>>>>>>
>>>>>> When device is removed, owl_uart_remove is called, which calls
>>>>>> uart_remove_one_port, which calls owl_uart_release_port, which writes
>>>>>> NULL to port->membase. At this point parallely, an interrupt could be
>>>>>> handled by owl_uart_irq which reads port->membase.
>>>>>>
>>>>>> This is because it is possible to remove device without closing a port.
>>>>>> Thus, we need to check it and call owl_uart_shutdown in owl_uart_remove.
>>>
>>> No, this makes no sense at all. The port is deregistered and hung up by
>>> uart_remove_one_port() (and the interrupt line is consequently disabled
>>> by the driver) before it is released so this can never happen.
>>
>> Thanks for the reply. I am not sure I understand. I could not find any
>> interrupt disabling in owl_uart_remove. Could you point out where/how is
>> the interrupt line is disabled before releasing the port?
>
> The interrupt line is disabled by owl_uart_shutdown(), which is called
> when uart_remove_one_port() hangs up an open tty. And as I mentioned
> this happens after deregistering the port (so no new opens) and before
> releasing the port.
>
> Johan
>
Thank you very much for the explanation. So, indeed shutdown is called
before releasing port. There is no need for a patch.
prev parent reply other threads:[~2021-06-25 7:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 11:04 [PATCH] tty: serial: owl: Fix data race in owl_uart_remove Saubhik Mukherjee
2021-06-17 11:22 ` Greg KH
2021-06-23 5:36 ` Saubhik Mukherjee
2021-06-23 7:16 ` Johan Hovold
2021-06-24 12:07 ` Saubhik Mukherjee
2021-06-24 12:29 ` Johan Hovold
2021-06-25 7:52 ` Saubhik Mukherjee [this message]
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=ff208383-aefa-17d0-891c-ee5a10edd1fe@gmail.com \
--to=saubhik.mukherjee@gmail.com \
--cc=andrianov@ispras.ru \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=johan@kernel.org \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).