LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [question] potential race between capinc_tty_init & capi_release
@ 2021-08-17 9:13 Saubhik Mukherjee
2021-08-17 16:28 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Saubhik Mukherjee @ 2021-08-17 9:13 UTC (permalink / raw)
To: isdn, gregkh, jirislaby, dsterba, jcmvbkbc, johannes, kuba
Cc: netdev, linux-kernel, andrianov
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [question] potential race between capinc_tty_init & capi_release
2021-08-17 9:13 [question] potential race between capinc_tty_init & capi_release Saubhik Mukherjee
@ 2021-08-17 16:28 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-08-17 16:28 UTC (permalink / raw)
To: Saubhik Mukherjee
Cc: isdn, jirislaby, dsterba, jcmvbkbc, johannes, kuba, netdev,
linux-kernel, andrianov
On Tue, Aug 17, 2021 at 02:43:22PM +0530, Saubhik Mukherjee wrote:
> In drivers/isdn/capi/capi.c, based on the output of a static analysis tool,
> we found the possibility of the following race condition:
Do you know of any isdn capi devices out there in the world right now?
>
> 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.
Would you be racing now if someone opened/closed the tty device node
before the char device node was created?
Anyway, this is really old and obsolete code, odds are it can just be
removed entirely.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-17 16:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 9:13 [question] potential race between capinc_tty_init & capi_release Saubhik Mukherjee
2021-08-17 16:28 ` Greg KH
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).