linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saubhik Mukherjee <saubhik.mukherjee@gmail.com>
To: isdn@linux-pingi.de, gregkh@linuxfoundation.org,
	jirislaby@kernel.org, dsterba@suse.com, jcmvbkbc@gmail.com,
	johannes@sipsolutions.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	andrianov@ispras.ru
Subject: [question] potential race between capinc_tty_init & capi_release
Date: Tue, 17 Aug 2021 14:43:22 +0530	[thread overview]
Message-ID: <af56f61a-6343-85fd-3efc-b3a2890246ac@gmail.com> (raw)

In drivers/isdn/capi/capi.c, based on the output of a static analysis 
tool, we found the possibility of the following race condition:

In capi_init, register_chrdev registers file operations callbacks, 
capi_fops. Then capinc_tty_init is executed.

Simultaneously the following chain of calls can occur (after a 
successful capi_open call).

capi_release -> capincci_free -> capincci_free_minor -> capiminor_free 
-> tty_unregister_device

tty_unregister_device reads capinc_tty_driver, which might not have been 
initialized at this point. So, we have a race between capi_release and 
capinc_tty_init.

If this is a possible race scenario, maybe moving register_chrdev after 
capinc_tty_init could fix it. But I am not sure if this will break 
something else. Please let me know if this is a potential race and can 
be fixed as mentioned.

Since this is based on a static analysis tool, this is not tested.

             reply	other threads:[~2021-08-17  9:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  9:13 Saubhik Mukherjee [this message]
2021-08-17 16:28 ` Greg KH

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=af56f61a-6343-85fd-3efc-b3a2890246ac@gmail.com \
    --to=saubhik.mukherjee@gmail.com \
    --cc=andrianov@ispras.ru \
    --cc=dsterba@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=isdn@linux-pingi.de \
    --cc=jcmvbkbc@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [question] potential race between capinc_tty_init & capi_release' \
    /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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox