Re: [PATCH 1/2] proc: add a helper for marking files as permanent by external consumers

From: Alexey Dobriyan
Date: Tue Apr 01 2025 - 07:14:33 EST


> +void proc_make_permanent(struct proc_dir_entry *de)
> +{
> + pde_make_permanent(de);
> +}
> +EXPORT_SYMBOL(proc_make_permanent);

no, no, no, no

this is wrong!

marking should be done in the context of a module!

the reason it is not exported is because the aren't safeguards against
module misuse

the flag is supposed to be used in case where
a) PDE itself is never removed and,
b) all the code supporting is never removed,
so that locking can be skipped

this it fine to mark /proc/filesystems because kernel controls it

this is fine to mark /proc/aaa if all module does is to write some
info to it and deletes it during rmmod

but it is not fine to mark /proc/aaa/bbb if "bbb" is created/deleted
while module is running,
locking _must_ be done in this case