lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <053ccd05-4f11-5be6-47c2-eee5c2f1fdc4@linaro.org>
Date:   Mon, 13 Jan 2020 11:34:55 +0800
From:   zhangfei <zhangfei.gao@...aro.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Arnd Bergmann <arnd@...db.de>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        jonathan.cameron@...wei.com, dave.jiang@...el.com,
        grant.likely@....com, jean-philippe <jean-philippe@...aro.org>,
        Jerome Glisse <jglisse@...hat.com>,
        ilias.apalodimas@...aro.org, francois.ozog@...aro.org,
        kenneth-lee-2012@...mail.com, Wangzhou <wangzhou1@...ilicon.com>,
        "haojian . zhuang" <haojian.zhuang@...aro.org>,
        guodong.xu@...aro.org, linux-accelerators@...ts.ozlabs.org,
        linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
        iommu@...ts.linux-foundation.org,
        Kenneth Lee <liguozhu@...ilicon.com>,
        Zaibo Xu <xuzaibo@...wei.com>
Subject: Re: [PATCH v11 2/4] uacce: add uacce driver

Hi, Greg

Thanks for the review.

On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:
> On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:
>> +static int uacce_fops_open(struct inode *inode, struct file *filep)
>> +{
>> +	struct uacce_mm *uacce_mm = NULL;
>> +	struct uacce_device *uacce;
>> +	struct uacce_queue *q;
>> +	int ret = 0;
>> +
>> +	uacce = xa_load(&uacce_xa, iminor(inode));
>> +	if (!uacce)
>> +		return -ENODEV;
>> +
>> +	if (!try_module_get(uacce->parent->driver->owner))
>> +		return -ENODEV;
> Why are you trying to grab the module reference of the parent device?
> Why is that needed and what is that going to help with here?
>
> This shouldn't be needed as the module reference of the owner of the
> fileops for this module is incremented, and the "parent" module depends
> on this module, so how could it be unloaded without this code being
> unloaded?
>
> Yes, if you build this code into the kernel and the "parent" driver is a
> module, then you will not have a reference, but when you remove that
> parent driver the device will be removed as it has to be unregistered
> before that parent driver can be removed from the system, right?
>
> Or what am I missing here?
The refcount here is preventing rmmod "parent" module after fd is opened,
since user driver has mmap kernel memory to user space, like mmio, which 
may still in-use.

With the refcount protection, rmmod "parent" module will fail until 
application free the fd.
log like: rmmod: ERROR: Module hisi_zip is in use
>
>> +static void uacce_release(struct device *dev)
>> +{
>> +	struct uacce_device *uacce = to_uacce_device(dev);
>> +
>> +	kfree(uacce);
>> +	uacce = NULL;
> That line didn't do anything :)
Yes, this is a mistake.
It is up to caller to set to NULL to prevent release multi times.

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ