Subject: Re: [PATCH v2] net: delete /proc THIS_MODULE references

From: Stephen Hemminger <[email-masked]>
Date: Mon, 15 Jan 2018 14:18:00 -0800

On Tue, 16 Jan 2018 00:42:40 +0300
Alexey Dobriyan <[email-masked]> wrote:

> /proc has been ignoring struct file_operations::owner field for 10 years.
> Specifically, it started with commit 786d7e1612f0b0adb6046f19b906609e4fe8b1ba
> ("Fix rmmod/read/write races in /proc entries"). Notice the chunk where
> inode->i_fop is initialized with proxy struct file_operations for
> regular files:
> 
> 	-               if (de->proc_fops)
> 	-                       inode->i_fop = de->proc_fops;
> 	+               if (de->proc_fops) {
> 	+                       if (S_ISREG(inode->i_mode))
> 	+                               inode->i_fop = &proc_reg_file_ops;
> 	+                       else
> 	+                               inode->i_fop = de->proc_fops;
> 	+               }
> 
> VFS stopped pinning module at this point.
> 
> Signed-off-by: Alexey Dobriyan <[email-masked]>

What happens if /proc file for the module is open and the module is unloaded?
Just because it is old doesn't mean that it wasn't a bug.