Re: [PATCH] drivers: isdn: capi: Fix data-race bug

From: Arnd Bergmann
Date: Wed Jul 22 2020 - 14:41:45 EST


On Wed, Jul 22, 2020 at 7:23 PM <madhuparnabhowmik10@xxxxxxxxx> wrote:
>
> From: Madhuparna Bhowmik <madhuparnabhowmik10@xxxxxxxxx>
>
> In capi_init(), after register_chrdev() the file operation callbacks
> can be called. However capinc_tty_init() is called later.
> Since capiminors and capinc_tty_driver are initialized in
> capinc_tty_init(), their initialization can race with their usage
> in various callbacks like in capi_release().
>
> Therefore, call capinc_tty_init() before register_chrdev to avoid
> such race conditions.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@xxxxxxxxx>

I don't think there are any users of this driver, but I had a look anyway.

The patch looks reasonable at first, but I'm not sure if you just
replace one race with another, since now the tty device can be
opened before the rest of the subsystem is initialized.

It's probably fine.

Arnd