[PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()

Luis Chamberlain posted 11 patches 3 years, 1 month ago
[PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Posted by Luis Chamberlain 3 years, 1 month ago
register_sysctl_paths() is only required if your child (directories)
have entries and pid_namespace does not. So use register_sysctl_init()
instead where we don't care about the return value and use
register_sysctl() where we do.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 kernel/pid_namespace.c | 3 +--
 kernel/pid_sysctl.h    | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 46e0d5a3f91f..b43eee07b00c 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -314,7 +314,6 @@ static struct ctl_table pid_ns_ctl_table[] = {
 	},
 	{ }
 };
-static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
 #endif	/* CONFIG_CHECKPOINT_RESTORE */
 
 int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
@@ -473,7 +472,7 @@ static __init int pid_namespaces_init(void)
 	pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC | SLAB_ACCOUNT);
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
-	register_sysctl_paths(kern_path, pid_ns_ctl_table);
+	register_sysctl_init("kernel", pid_ns_ctl_table);
 #endif
 
 	register_pid_ns_sysctl_table_vm();
diff --git a/kernel/pid_sysctl.h b/kernel/pid_sysctl.h
index e22d072e1e24..d67a4d45bb42 100644
--- a/kernel/pid_sysctl.h
+++ b/kernel/pid_sysctl.h
@@ -46,10 +46,9 @@ static struct ctl_table pid_ns_ctl_table_vm[] = {
 	},
 	{ }
 };
-static struct ctl_path vm_path[] = { { .procname = "vm", }, { } };
 static inline void register_pid_ns_sysctl_table_vm(void)
 {
-	register_sysctl_paths(vm_path, pid_ns_ctl_table_vm);
+	register_sysctl("vm", pid_ns_ctl_table_vm);
 }
 #else
 static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns) {}
-- 
2.39.1
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Posted by Jeff Xu 3 years, 1 month ago
On Thu, Mar 2, 2023 at 12:28 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> register_sysctl_paths() is only required if your child (directories)
> have entries and pid_namespace does not. So use register_sysctl_init()
> instead where we don't care about the return value and use
> register_sysctl() where we do.
>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  kernel/pid_namespace.c | 3 +--
>  kernel/pid_sysctl.h    | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
> index 46e0d5a3f91f..b43eee07b00c 100644
> --- a/kernel/pid_namespace.c
> +++ b/kernel/pid_namespace.c
> @@ -314,7 +314,6 @@ static struct ctl_table pid_ns_ctl_table[] = {
>         },
>         { }
>  };
> -static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
>  #endif /* CONFIG_CHECKPOINT_RESTORE */
>
>  int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
> @@ -473,7 +472,7 @@ static __init int pid_namespaces_init(void)
>         pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC | SLAB_ACCOUNT);
>
>  #ifdef CONFIG_CHECKPOINT_RESTORE
> -       register_sysctl_paths(kern_path, pid_ns_ctl_table);
> +       register_sysctl_init("kernel", pid_ns_ctl_table);
>  #endif
>
>         register_pid_ns_sysctl_table_vm();
> diff --git a/kernel/pid_sysctl.h b/kernel/pid_sysctl.h
> index e22d072e1e24..d67a4d45bb42 100644
> --- a/kernel/pid_sysctl.h
> +++ b/kernel/pid_sysctl.h
> @@ -46,10 +46,9 @@ static struct ctl_table pid_ns_ctl_table_vm[] = {
>         },
>         { }
>  };
> -static struct ctl_path vm_path[] = { { .procname = "vm", }, { } };
>  static inline void register_pid_ns_sysctl_table_vm(void)
>  {
> -       register_sysctl_paths(vm_path, pid_ns_ctl_table_vm);
> +       register_sysctl("vm", pid_ns_ctl_table_vm);
>  }
>  #else
>  static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns) {}
> --
> 2.39.1
>
Acked-by: Jeff Xu <jeffxu@google.com>
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Posted by Luis Chamberlain 3 years, 1 month ago
On Thu, Mar 02, 2023 at 03:13:54PM -0800, Jeff Xu wrote:
> On Thu, Mar 2, 2023 at 12:28 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
> >  kernel/pid_sysctl.h    | 3 +--
> >  2 files changed, 2 insertions(+), 4 deletions(-)
> >
> Acked-by: Jeff Xu <jeffxu@google.com>

Andrew, kernel/pid_sysctl.h is new, not on v6.3-rc1 and so I cannot
carry this on sysctl-next. Can you carry this patch on your tree?

I see Eric Biggers already took in the fs-verity patch, so I will drop
that from my queue.

I can take the rest in this series.

I will also hold off on the last patch which deprecates the routine
register_sysctl_paths() until after say the first part of the merge
window.

This will allow all of our trees to work on linux-next without conflict.

Let me know if this is OK with you and Eric!

  Luis
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Posted by Eric Biggers 3 years, 1 month ago
On Thu, Mar 09, 2023 at 02:11:27PM -0800, Luis Chamberlain wrote:
> On Thu, Mar 02, 2023 at 03:13:54PM -0800, Jeff Xu wrote:
> > On Thu, Mar 2, 2023 at 12:28 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
> > >  kernel/pid_sysctl.h    | 3 +--
> > >  2 files changed, 2 insertions(+), 4 deletions(-)
> > >
> > Acked-by: Jeff Xu <jeffxu@google.com>
> 
> Andrew, kernel/pid_sysctl.h is new, not on v6.3-rc1 and so I cannot
> carry this on sysctl-next. Can you carry this patch on your tree?
> 
> I see Eric Biggers already took in the fs-verity patch, so I will drop
> that from my queue.
> 
> I can take the rest in this series.
> 
> I will also hold off on the last patch which deprecates the routine
> register_sysctl_paths() until after say the first part of the merge
> window.
> 
> This will allow all of our trees to work on linux-next without conflict.
> 
> Let me know if this is OK with you and Eric!
> 

That's fine with me.  I applied the fsverity patch based on your cover letter
that said it was okay
(https://lore.kernel.org/r/20230302202826.776286-1-mcgrof@kernel.org).  If you'd
like to take all the patches so that you can remove register_sysctl_paths() in
the same cycle, that would be fine too; it's up to you.

- Eric
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Posted by Luis Chamberlain 3 years, 1 month ago
On Thu, Mar 09, 2023 at 08:14:33PM -0800, Eric Biggers wrote:
> On Thu, Mar 09, 2023 at 02:11:27PM -0800, Luis Chamberlain wrote:
> > On Thu, Mar 02, 2023 at 03:13:54PM -0800, Jeff Xu wrote:
> > > On Thu, Mar 2, 2023 at 12:28 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
> > > >  kernel/pid_sysctl.h    | 3 +--
> > > >  2 files changed, 2 insertions(+), 4 deletions(-)
> > > >
> > > Acked-by: Jeff Xu <jeffxu@google.com>
> > 
> > Andrew, kernel/pid_sysctl.h is new, not on v6.3-rc1 and so I cannot
> > carry this on sysctl-next. Can you carry this patch on your tree?
> > 
> > I see Eric Biggers already took in the fs-verity patch, so I will drop
> > that from my queue.
> > 
> > I can take the rest in this series.
> > 
> > I will also hold off on the last patch which deprecates the routine
> > register_sysctl_paths() until after say the first part of the merge
> > window.
> > 
> > This will allow all of our trees to work on linux-next without conflict.
> > 
> > Let me know if this is OK with you and Eric!
> > 
> 
> That's fine with me.  I applied the fsverity patch based on your cover letter
> that said it was okay
> (https://lore.kernel.org/r/20230302202826.776286-1-mcgrof@kernel.org).

Yeah it perfectly fine!

> If you'd
> like to take all the patches so that you can remove register_sysctl_paths() in
> the same cycle, that would be fine too; it's up to you.

Nah it's fine, no rush in this. One small step at a time.

  Luis
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Posted by Andrew Morton 3 years, 1 month ago
On Thu, 9 Mar 2023 14:11:27 -0800 Luis Chamberlain <mcgrof@kernel.org> wrote:

> Andrew, kernel/pid_sysctl.h is new, not on v6.3-rc1 and so I cannot
> carry this on sysctl-next. Can you carry this patch on your tree?

Sure, no probs.
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Posted by Luis Chamberlain 3 years ago
On Thu, Mar 09, 2023 at 02:27:46PM -0800, Andrew Morton wrote:
> On Thu, 9 Mar 2023 14:11:27 -0800 Luis Chamberlain <mcgrof@kernel.org> wrote:
> 
> > Andrew, kernel/pid_sysctl.h is new, not on v6.3-rc1 and so I cannot
> > carry this on sysctl-next. Can you carry this patch on your tree?
> 
> Sure, no probs.

Andrew, this one patch will have to go through your tree as kernel/pid_sysctl.h
only exist on your tree. I'll drop it on my end!

Thanks!

  Luis