[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZUyHSs+oI9AsQdZE@yilunxu-OptiPlex-7050>
Date: Thu, 9 Nov 2023 15:16:26 +0800
From: Xu Yilun <yilun.xu@...ux.intel.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Marco Pagani <marpagan@...hat.com>,
Moritz Fischer <mdf@...nel.org>, Wu Hao <hao.wu@...el.com>,
Xu Yilun <yilun.xu@...el.com>, Tom Rix <trix@...hat.com>,
Alan Tull <atull@...nsource.altera.com>,
linux-fpga@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH] fpga: remove module reference counting from core
components
On Thu, Nov 09, 2023 at 06:27:24AM +0100, Greg Kroah-Hartman wrote:
> On Thu, Nov 09, 2023 at 01:07:42PM +0800, Xu Yilun wrote:
> > On Wed, Nov 08, 2023 at 05:20:53PM +0100, Greg Kroah-Hartman wrote:
> > > On Wed, Nov 08, 2023 at 11:52:52PM +0800, Xu Yilun wrote:
> > > > > >>
> > > > > >> In fpga_region_get() / fpga_region_put(): call get_device() before
> > > > > >> acquiring the mutex and put_device() after having released the mutex
> > > > > >> to avoid races.
> > >
> > > Why do you need another reference count with a lock? You already have
> > > that with the calls to get/put_device().
> >
> > The low-level driver module could still be possibly unloaded at the same
> > time, if so, when FPGA core run some callbacks provided by low-level driver
> > module, its referenced page of code is unmapped...
>
> Then something is designed wrong here, the unloading of the low-level
> driver should remove the access to the device itself. Perhaps fix that?
Actually the low-level driver module on its own has no way to garantee its
own code page of callbacks not accessed. It *is* accessing its code page
when it tries (to release) any protection.
Core code must help, and something like file_operations.owner is an
effective way.
Thanks,
Yilun
Powered by blists - more mailing lists