lkml.org 
[lkml]   [2020]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] uacce: unmap remaining mmapping from user space
From
Date
Hi,
On 2020/2/25 16:33, zhangfei wrote:
> Hi, Zaibo
>
> On 2020/2/24 下午3:17, Xu Zaibo wrote:
>>> @@ -585,6 +595,13 @@ void uacce_remove(struct uacce_device *uacce)
>>> cdev_device_del(uacce->cdev, &uacce->dev);
>>> xa_erase(&uacce_xa, uacce->dev_id);
>>> put_device(&uacce->dev);
>>> +
>>> + /*
>>> + * unmap remainning mapping from user space, preventing user still
>>> + * access the mmaped area while parent device is already removed
>>> + */
>>> + if (uacce->inode)
>>> + unmap_mapping_range(uacce->inode->i_mapping, 0, 0, 1);
>> Should we unmap them at the first of 'uacce_remove', and before
>> 'uacce_put_queue'?
>>
> We can do this,
> Though it does not matter, since user space can not interrupt kernel
> function uacce_remove.
>
I think it matters :)

Image that the process holds the uacce queue is running(read and write
the queue), then you do 'uacce_remove'.
The process is running(read and write the queue) well in the time
between 'uacce_put_queue' and
'unmap_mapping_range', however, the queue with its DMA memory may be
gotten and used by
other guys in this time, since you have released them in kernel. As a
result, the running process will be a disaster.

cheers,
Zaibo

.


> Thanks
> .
>


\
 
 \ /
  Last update: 2020-02-25 10:14    [W:0.034 / U:0.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site