From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolai Stange Subject: Re: debugfs_remove_recursive() while a file is in use by userspace Date: Mon, 28 Dec 2015 21:42:49 +0100 Message-ID: <87poxqqp86.fsf@gmail.com> References: Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=THLvfvUAxfHoAfp2OSjqkG2NBQ3gKtYoF++u86R5onc=; b=YwdpdhDxlAGQNo2ZBot1avKONs8504hg3kKGNi2J8SnIZ8HmqbxfBVfKayrXxT7g90 sVrGf18UMqQHN0RMt3iKfXva+59qir+HyHhXYdzUXJywX68wdrnI2LMyNDC8hkNnNLDc QTp0CFHG5vISnpmHWSSi6tOOOgjBNeat2wkKAPZY+K09sDgdH9/O3/Eg4+3ocDAnNTHt pNIPL58rRR+zkaLLsS6Pfx8GAKRKBHS8+dRF/nPraIK9Lp4sCA/h+S+lsEWRUK1ikKXx 7lt1XLhnkvbSAR2Pf70teki8ZpkoHlxkE9M6jG7t1PrYy2pW4JH0u7ZENZ3nCk8kUkFE taqg== In-Reply-To: (Rajat Jain's message of "Mon, 28 Dec 2015 12:27:22 -0800") Sender: linux-newbie-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Rajat Jain Cc: "linux-kernel@vger.kernel.org" , linux-newbie@vger.kernel.org, Greg Kroah-Hartman Hi Rajat, Rajat Jain writes: > Hi, > > I wanted to understand the behavior taken when a module calls > debugfs_remove_recursive() on a directory, while files under that > directory may still be in use by the userspace (for instance an > ongoing read / write operation). > > Does the function wait > > (1) until all the currently executing file operation methods > (read/write/map etc) have returned? > OR > (2) until the user has given up all references (descriptors) to the > files under the directory (i.e. until release() method has been > called)? The current state is that both question are to be answered with "no", i.e. debugfs file removal is racy. I've recently sent a patch addressing this issue: https://lkml.kernel.org/g/87y4dfukzy.fsf@gmail.com Basically, it turns the answer to your first question into "yes". Subsequent reads/writes will return a -EIO. That patch (series) is still under review though. Further reference can be found in the *sub*-thread rooted at http://thread.gmane.org/gmane.linux.kernel/1452470/focus=1467314 Best, Nicolai -- To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbbL1Um7 (ORCPT ); Mon, 28 Dec 2015 15:42:59 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:33941 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752729AbbL1Umw (ORCPT ); Mon, 28 Dec 2015 15:42:52 -0500 From: Nicolai Stange To: Rajat Jain Cc: "linux-kernel\@vger.kernel.org" , linux-newbie@vger.kernel.org, Greg Kroah-Hartman Subject: Re: debugfs_remove_recursive() while a file is in use by userspace References: Date: Mon, 28 Dec 2015 21:42:49 +0100 In-Reply-To: (Rajat Jain's message of "Mon, 28 Dec 2015 12:27:22 -0800") Message-ID: <87poxqqp86.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rajat, Rajat Jain writes: > Hi, > > I wanted to understand the behavior taken when a module calls > debugfs_remove_recursive() on a directory, while files under that > directory may still be in use by the userspace (for instance an > ongoing read / write operation). > > Does the function wait > > (1) until all the currently executing file operation methods > (read/write/map etc) have returned? > OR > (2) until the user has given up all references (descriptors) to the > files under the directory (i.e. until release() method has been > called)? The current state is that both question are to be answered with "no", i.e. debugfs file removal is racy. I've recently sent a patch addressing this issue: https://lkml.kernel.org/g/87y4dfukzy.fsf@gmail.com Basically, it turns the answer to your first question into "yes". Subsequent reads/writes will return a -EIO. That patch (series) is still under review though. Further reference can be found in the *sub*-thread rooted at http://thread.gmane.org/gmane.linux.kernel/1452470/focus=1467314 Best, Nicolai