diff mbox series

[05/11] loadpin: simplify sysctls use with register_sysctl()

Message ID 20230302202826.776286-6-mcgrof@kernel.org (mailing list archive)
State Handled Elsewhere
Headers show
Series sysctl: deprecate register_sysctl_paths() | expand

Commit Message

Luis Chamberlain March 2, 2023, 8:28 p.m. UTC
register_sysctl_paths() is not required, we can just use
register_sysctl() with the required path specified.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 security/loadpin/loadpin.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Kees Cook March 2, 2023, 10:56 p.m. UTC | #1
On Thu, Mar 02, 2023 at 12:28:20PM -0800, Luis Chamberlain wrote:
> register_sysctl_paths() is not required, we can just use
> register_sysctl() with the required path specified.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

Acked-by: Kees Cook <keescook@chromium.org>
John Johansen March 2, 2023, 10:58 p.m. UTC | #2
On 3/2/23 12:28, Luis Chamberlain wrote:
> register_sysctl_paths() is not required, we can just use
> register_sysctl() with the required path specified.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: John Johansen <john.johansen@canonical.com>

> ---
>   security/loadpin/loadpin.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
> index d73a281adf86..c971464b4ad5 100644
> --- a/security/loadpin/loadpin.c
> +++ b/security/loadpin/loadpin.c
> @@ -52,12 +52,6 @@ static bool deny_reading_verity_digests;
>   #endif
>   
>   #ifdef CONFIG_SYSCTL
> -static struct ctl_path loadpin_sysctl_path[] = {
> -	{ .procname = "kernel", },
> -	{ .procname = "loadpin", },
> -	{ }
> -};
> -
>   static struct ctl_table loadpin_sysctl_table[] = {
>   	{
>   		.procname       = "enforce",
> @@ -262,7 +256,7 @@ static int __init loadpin_init(void)
>   		enforce ? "" : "not ");
>   	parse_exclude();
>   #ifdef CONFIG_SYSCTL
> -	if (!register_sysctl_paths(loadpin_sysctl_path, loadpin_sysctl_table))
> +	if (!register_sysctl("kernel/loadpin", loadpin_sysctl_table))
>   		pr_notice("sysctl registration failed!\n");
>   #endif
>   	security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");
diff mbox series

Patch

diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
index d73a281adf86..c971464b4ad5 100644
--- a/security/loadpin/loadpin.c
+++ b/security/loadpin/loadpin.c
@@ -52,12 +52,6 @@  static bool deny_reading_verity_digests;
 #endif
 
 #ifdef CONFIG_SYSCTL
-static struct ctl_path loadpin_sysctl_path[] = {
-	{ .procname = "kernel", },
-	{ .procname = "loadpin", },
-	{ }
-};
-
 static struct ctl_table loadpin_sysctl_table[] = {
 	{
 		.procname       = "enforce",
@@ -262,7 +256,7 @@  static int __init loadpin_init(void)
 		enforce ? "" : "not ");
 	parse_exclude();
 #ifdef CONFIG_SYSCTL
-	if (!register_sysctl_paths(loadpin_sysctl_path, loadpin_sysctl_table))
+	if (!register_sysctl("kernel/loadpin", loadpin_sysctl_table))
 		pr_notice("sysctl registration failed!\n");
 #endif
 	security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");