Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757030AbcJGUsw (ORCPT ); Fri, 7 Oct 2016 16:48:52 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:46872 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753847AbcJGUsv (ORCPT ); Fri, 7 Oct 2016 16:48:51 -0400 Date: Fri, 7 Oct 2016 21:48:36 +0100 From: Al Viro To: Calvin Owens Cc: Jeff Layton , "J. Bruce Fields" , Rusty Russell , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] fs: Assert on module file_operations without an owner Message-ID: <20161007204836.GR19539@ZenIV.linux.org.uk> References: <48414ef29337b54e2a842bd841f73f01ab74ebe7.1475872278.git.calvinowens@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48414ef29337b54e2a842bd841f73f01ab74ebe7.1475872278.git.calvinowens@fb.com> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1192 Lines: 23 On Fri, Oct 07, 2016 at 01:35:52PM -0700, Calvin Owens wrote: > Omitting the owner field in file_operations declared in modules is an > easy mistake to make, and can result in crashes when the module is > unloaded while userspace is poking the file. > > This patch modifies fops_get() to WARN when it encounters a NULL owner, > since in this case it cannot take a reference on the containing module. NAK. This is complete crap - we do *NOT* need ->owner on a lot of file_operations. * we do not need that on file_operations of a regular file or directory on a normal filesystem, since that filesystem is not going away until the file has been closed - ->f_path.mnt is holding a reference to vfsmount, which is holding a reference to superblock, which is holding a reference to file_system_type, which is holding a reference to _its_ ->owner. * we do not need that on anything on procfs - module removal is legal while a procfs file is opened; its cleanup will be blocked for the duration of ->read(), ->write(), etc. calls. If anything, we would be better off with modifications that would get rid of ->owner on file_operations. It's not trivial to do, but it might be not impossible.