Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3434785ybv; Tue, 25 Feb 2020 01:13:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwgOa69e0KjvIliguMN5fJRy0aLxiyoSYFDkTla8DGucx9eidAPtcm4x66KFM/ycq6kl13W X-Received: by 2002:a9d:34c:: with SMTP id 70mr41176541otv.174.1582622029898; Tue, 25 Feb 2020 01:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582622029; cv=none; d=google.com; s=arc-20160816; b=H9T9fVk6t9YolZiQAVNZ379x99KMSniU32vajO5bxTVhOj39yzB2tjqo/lJ+1Pv1Jw 8pPE8lUcDD1DaX5vWbBjQ5mVAUOpCXxMSVySM/a+aojcZQNMvE/MfspAZDsnCCNOQJxZ mh2xBCqu6mQmukA5igJkb+vuvpGFDI1C41+AHNaTI3nkUs7HXZF2M7IsZn3LmKGrf2EY NhyaOorfeOd/srRoVdL/Vkj9pI+kF8KJUWIuWvue2OWR+ihy7eAdFkEJ+WX8Q76ENRvy etvpsXsB0BXloScMXiNlNAqbpB6j7isUyb3tVlypyYbUOs6TaTRle8souSeVbDclsARv /U4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=bvklEeC9P70Zpxda+HNl+MpOok60jp5pD+dHBZJTIyU=; b=JPX+0gExUBevPmsH+C4vS47l9zAHAiW45fbmHS3fO6k5/QI4T2RE+hYvJBXY/GH6g5 AflrrH3Vfy1QupJ8LZNV6VAG3xLh+I+42NxMiEGJKCg4hSrn5sbSBGHqRH22TVmYyEvQ nYdDF979l0w6Ho+LyA5cjZi6+8euWyVElapTAk3YYCitYcuhjgiBjPDFyZ0K9b0Zw9Np lk7b+BPd10UlJfM2y2d+OP2Hg1HBSOw5iMpEG6h5GrcLex7GvYVDM/BsSlSD22mCIbCA wX5jPSfEZ3yIACUWq8qyD+AJXOzgEP7mraCLb5i/G5co9Y6VAcQqUAI2/oGe3AhCL6fC XMBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si7819333otf.141.2020.02.25.01.13.37; Tue, 25 Feb 2020 01:13:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729624AbgBYJNd (ORCPT + 99 others); Tue, 25 Feb 2020 04:13:33 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:10687 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726916AbgBYJNd (ORCPT ); Tue, 25 Feb 2020 04:13:33 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9490EC4477B67687CCAC; Tue, 25 Feb 2020 17:13:30 +0800 (CST) Received: from [127.0.0.1] (10.67.101.242) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Feb 2020 17:13:19 +0800 Subject: Re: [PATCH] uacce: unmap remaining mmapping from user space To: zhangfei , Greg Kroah-Hartman , Arnd Bergmann , Herbert Xu , , , , jean-philippe , Jerome Glisse , , , , Wangzhou , "haojian . zhuang" , References: <1582528016-2873-1-git-send-email-zhangfei.gao@linaro.org> CC: , , , From: Xu Zaibo Message-ID: <844f8fc1-1c6c-0102-5412-df799cd327c5@huawei.com> Date: Tue, 25 Feb 2020 17:13:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.101.242] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > . >