Re: [PATCH RFC 18/38] proc: don't WARN about a name that is already registered
From: Alexey Dobriyan
Date: Wed Nov 04 2026 - 13:45:00 EST
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -401,9 +401,10 @@ struct proc_dir_entry *proc_register(struct proc_dir_entry *dir,
> write_lock(&proc_subdir_lock);
> dp->parent = dir;
> if (pde_subdir_insert(dir, dp) == false) {
> - WARN(1, "proc_dir_entry '%s/%s' already registered\n",
> - dir->name, dp->name);
> write_unlock(&proc_subdir_lock);
> + pr_warn("proc_dir_entry '%s/%s' already registered\n",
> + dir->name, dp->name);
> + dump_stack();
> goto out_free_inum;
> }
> write_unlock(&proc_subdir_lock);
I don't like this patch.
WARN is there to make bugs noticeable, /proc entries aren't supposed to be
created randomly unlike regular files so deleting non-existent name or
registering twice is probably a bug.
Now, some names do come from userspace but it is up to subsystems to
find duplicates and return errors (and sanitize for dots/slashes!).
In userspace mkdir;mkdir returns error second time, as well as
unlink;unlink. In kernel error is BUG/WARN (like it is now) and it is up
to subsystem to evade it.
/proc/alexey