* [PATCH] proc: make struct proc_dir_entry::name const
@ 2023-11-29 9:46 Alexey Dobriyan
2023-11-29 22:07 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2023-11-29 9:46 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel
Multiply ::name into "mut_name" and "name" which is "const char*".
PDE's name must not be mutated on live PDE, hint modules they should not
do it.
Many other members must not be mutated live as well, but start with
obvious one.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
fs/proc/generic.c | 2 +-
fs/proc/internal.h | 5 ++++-
fs/proc/proc_net.c | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -436,7 +436,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
}
}
- memcpy(ent->name, fn, qstr.len + 1);
+ memcpy(ent->mut_name, fn, qstr.len + 1);
ent->namelen = qstr.len;
ent->mode = mode;
ent->nlink = nlink;
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -59,7 +59,10 @@ struct proc_dir_entry {
struct proc_dir_entry *parent;
struct rb_root subdir;
struct rb_node subdir_node;
- char *name;
+ union {
+ const char *name;
+ char *mut_name;
+ };
umode_t mode;
u8 flags;
u8 namelen;
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -368,7 +368,7 @@ static __net_init int proc_net_ns_init(struct net *net)
netd->namelen = 3;
netd->parent = &proc_root;
netd->name = netd->inline_name;
- memcpy(netd->name, "net", 4);
+ memcpy(netd->mut_name, "net", 4);
uid = make_kuid(net->user_ns, 0);
if (!uid_valid(uid))
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] proc: make struct proc_dir_entry::name const
2023-11-29 9:46 [PATCH] proc: make struct proc_dir_entry::name const Alexey Dobriyan
@ 2023-11-29 22:07 ` Andrew Morton
2023-11-30 6:58 ` Alexey Dobriyan
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2023-11-29 22:07 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: linux-kernel
On Wed, 29 Nov 2023 12:46:57 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
> Multiply ::name into "mut_name" and "name" which is "const char*".
>
> PDE's name must not be mutated on live PDE, hint modules they should not
> do it.
Do any modules do this? If so, we just broke them. If not, why bother
with this change?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] proc: make struct proc_dir_entry::name const
2023-11-29 22:07 ` Andrew Morton
@ 2023-11-30 6:58 ` Alexey Dobriyan
0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2023-11-30 6:58 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
On Wed, Nov 29, 2023 at 02:07:05PM -0800, Andrew Morton wrote:
> On Wed, 29 Nov 2023 12:46:57 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
>
> > Multiply ::name into "mut_name" and "name" which is "const char*".
> >
> > PDE's name must not be mutated on live PDE, hint modules they should not
> > do it.
>
> Do any modules do this?
x86_64 allmodconfig is OK, so in-kernel modules are OK.
> If so, we just broke them.
pff...
> If not, why bother with this change?
I don't know, out of love for humanity and increasing OOT modules
code quality. I don't think I've seen changing pde->name, but then
it is OOT modules we are talking about.
C doesn't have a notion for write once members, oh well.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-30 6:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29 9:46 [PATCH] proc: make struct proc_dir_entry::name const Alexey Dobriyan
2023-11-29 22:07 ` Andrew Morton
2023-11-30 6:58 ` Alexey Dobriyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®