[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200330122518.GA12077@madhuparna-HP-Notebook>
Date: Mon, 30 Mar 2020 17:55:18 +0530
From: Madhuparna Bhowmik <madhuparnabhowmik10@...il.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: madhuparnabhowmik10@...il.com, hariprasad.kelam@...il.com,
colin.king@...onical.com, tony.olech@...ndigitalsystems.com,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
andrianov@...ras.ru
Subject: Re: Possible data-race related bug in u132_hcd module.
On Mon, Mar 30, 2020 at 02:02:07PM +0200, Greg KH wrote:
> On Mon, Mar 30, 2020 at 05:22:43PM +0530, madhuparnabhowmik10@...il.com wrote:
> > Hi,
> >
> > This bug is found by Linux Driver Verification project (linuxtesting.org).
> >
> > The bug is related to the parallel execution of u132_probe() function and u132_hcd_exit() function in u132_hcd.c. In case the module is unloaded when the probe function is executing there can be data race as the mutex lock u132_module_lock is not used properly.
>
> Please note that module unloading, while a nice thing to have, is never
> something that happens automatically :)
>
> > i) Usage of mutex lock only when writing into the u132_exiting variable in u132_hcd_exit(). The lock is not used when this variable is read in u132_probe().
> >
> > Moreover, this variable does not serve its purpose, as even if locking is used while the u132_exiting variable is read in probe(), the function may still miss that exit function is executing if it acquires the mutex before exit() function does.
> >
> > How to fix this?
> >
> > ii) Usage of mutex while adding entries in u132_static_list in probe function but not in exit function while unregistering.
> > This should be easy to fix by holding the mutex in the exit function as well.
> >
> > There can be other synchronization problems related to the usage of u132_module_lock in this module, I have only spotted these so far.
> >
> > Please let me know if this bug report is helpful and I can send a patch fixing it.
>
> Please just send a patch, no need to ever ask if you should, that's the
> best way to report and fix anything.
>
Sure, I will do it.
Thank you,
Madhuparna
> thanks,
>
> greg k-h
Powered by blists - more mailing lists