Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-10 Thread Johannes Berg
On Sat, 2020-10-10 at 11:38 +0200, Greg KH wrote: > On Fri, Oct 09, 2020 at 10:48:09AM +0200, Johannes Berg wrote: > > On Fri, 2020-10-09 at 10:47 +0200, Greg KH wrote: > > > > > > I think adding the .owner everywhere would be good, and perhaps we can > > > > somehow put a check somewhere like > >

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-10 Thread Greg KH
On Fri, Oct 09, 2020 at 10:48:09AM +0200, Johannes Berg wrote: > On Fri, 2020-10-09 at 10:47 +0200, Greg KH wrote: > > > > I think adding the .owner everywhere would be good, and perhaps we can > > > somehow put a check somewhere like > > > > > > WARN_ON(is_module_address((unsigned long)fops) &

RE: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread David Laight
From: Johannes Berg > Sent: 09 October 2020 09:45 > > On Fri, 2020-10-09 at 08:34 +, David Laight wrote: > > ... > > Does it ever make any sense to set .owner to anything other than > > THIS_MODULE? > > No. But I believe THIS_MODULE is NULL for built-in code, so we can't > just WARN_ON(!fops-

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Johannes Berg
On Fri, 2020-10-09 at 10:47 +0200, Greg KH wrote: > > I think adding the .owner everywhere would be good, and perhaps we can > > somehow put a check somewhere like > > > > WARN_ON(is_module_address((unsigned long)fops) && !fops->owner); > > > > to prevent the issue in the future? > > That w

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Greg KH
On Fri, Oct 09, 2020 at 10:19:02AM +0200, Johannes Berg wrote: > On Fri, 2020-10-09 at 10:16 +0200, Greg KH wrote: > > On Fri, Oct 09, 2020 at 10:06:14AM +0200, Johannes Berg wrote: > > > We used to say the proxy_fops weren't needed and it wasn't an issue, and > > > then still implemented it. Dunno

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Johannes Berg
On Fri, 2020-10-09 at 08:34 +, David Laight wrote: > > > I think adding the .owner everywhere would be good, and perhaps we can > > somehow put a check somewhere like > > > > WARN_ON(is_module_address((unsigned long)fops) && !fops->owner); > > > > to prevent the issue in the future? > >

RE: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread David Laight
From: Johannes Berg > Sent: 09 October 2020 09:19 > > On Fri, 2020-10-09 at 10:16 +0200, Greg KH wrote: > > On Fri, Oct 09, 2020 at 10:06:14AM +0200, Johannes Berg wrote: > > > We used to say the proxy_fops weren't needed and it wasn't an issue, and > > > then still implemented it. Dunno. I'm not

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Johannes Berg
On Fri, 2020-10-09 at 10:16 +0200, Greg KH wrote: > On Fri, Oct 09, 2020 at 10:06:14AM +0200, Johannes Berg wrote: > > We used to say the proxy_fops weren't needed and it wasn't an issue, and > > then still implemented it. Dunno. I'm not really too concerned about it > > myself, only root can hold

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Greg KH
On Fri, Oct 09, 2020 at 10:06:14AM +0200, Johannes Berg wrote: > We used to say the proxy_fops weren't needed and it wasn't an issue, and > then still implemented it. Dunno. I'm not really too concerned about it > myself, only root can hold the files open and remove modules ... proxy_fops were nee

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Johannes Berg
On Fri, 2020-10-09 at 10:03 +0200, Greg KH wrote: > For lots of debugfs files, .owner should already be set, if you use the > DEFINE_SIMPLE_ATTRIBUTE() or DEFINE_DEBUGFS_ATTRIBUTE() macros. > > But yes, not all. Right. You didn't see the original thread: https://lore.kernel.org/netdev/20201008

Re: [CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Greg KH
On Fri, Oct 09, 2020 at 09:53:06AM +0200, Johannes Berg wrote: > [RFF = Request For Flaming] > > THIS IS PROBABLY COMPLETELY CRAZY. > > Currently, if a module is unloaded while debugfs files are being > kept open, things crash since the ->release() method is called > only at the actual release, d

[CRAZY-RFF] debugfs: track open files and release on remove

2020-10-09 Thread Johannes Berg
[RFF = Request For Flaming] THIS IS PROBABLY COMPLETELY CRAZY. Currently, if a module is unloaded while debugfs files are being kept open, things crash since the ->release() method is called only at the actual release, despite the proxy_fops, and then the code is no longer around. The correct wa