Skip to contentSkip to conversation

security: keys: Make sysctl table const

PATCH In review Ricardo B. Marliere 4 participants 6 messages Jan 23, 2025 – Mar 1, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 security: keys: Make sysctl table const

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows for struct ctl_table to be in read-only memory. Move key_sysctls to be declared at build time, instead of having to be dynamically allocated at boot time.

---
 security/keys/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/sysctl.c +1 -1
index 91f000eef3ad82370250e5238d9c9c80757aab61..cde08c478f3272081304e6db34e36b64ce0d321a 100644
@@ -9,7 +9,7 @@
 #include <linux/sysctl.h>
 #include "internal.h"
 
-static struct ctl_table key_sysctls[] = {
+static const struct ctl_table key_sysctls[] = {
 	{
 		.procname = "maxkeys",
 		.data = &key_quota_maxkeys,

---
base-commit: 714d87c90a766e6917f7d69f618b864d350f09d3
change-id: 20250123-sysctl_const-pcmoore-fa14389b8329

Best regards,

Signature · 1 line
Ricardo B. Marliere <[email protected]>
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ricardo B. Marliere

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows for struct ctl_table to be in read-only memory. Move key_sysctls to be declared at build time, instead of having to be dynamically allocated at boot time.

Quoted 6 lines
---
 security/keys/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Looks fine to me. David or Jarkko, this looks like something for the keys tree, yes?

Quoted 21 lines
security/keys/sysctl.c +1 -2
index 91f000eef3ad82370250e5238d9c9c80757aab61..cde08c478f3272081304e6db34e36b64ce0d321a 100644
@@ -9,7 +9,7 @@
 #include <linux/sysctl.h>
 #include "internal.h"
 
-static struct ctl_table key_sysctls[] = {
+static const struct ctl_table key_sysctls[] = {
        {
                .procname = "maxkeys",
                .data = &key_quota_maxkeys,
 
---

base-commit: 714d87c90a766e6917f7d69f618b864d350f09d3
change-id: 20250123-sysctl_const-pcmoore-fa14389b8329

Best regards,
--
Ricardo B. Marliere <[email protected]>

Signature · 1 line
paul-moore.com
#2 lore raw

Hi Paul,

Quoted 15 lines · Paul Moore
Quoted 6 lines · Ricardo B. Marliere

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows for struct ctl_table to be in read-only memory. Move key_sysctls to be declared at build time, instead of having to be dynamically allocated at boot time.

Quoted 6 lines
---
 security/keys/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines

Looks fine to me. David or Jarkko, this looks like something for the keys tree, yes?

Thank you for the review, but I believe this has been done here:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1751f872cc97f992ed5c4c72c55588db1f0021e1

Quoted 22 lines
Quoted 22 lines
security/keys/sysctl.c +1 -2
index 91f000eef3ad82370250e5238d9c9c80757aab61..cde08c478f3272081304e6db34e36b64ce0d321a 100644
@@ -9,7 +9,7 @@
 #include <linux/sysctl.h>
 #include "internal.h"
 
-static struct ctl_table key_sysctls[] = {
+static const struct ctl_table key_sysctls[] = {
        {
                .procname = "maxkeys",
                .data = &key_quota_maxkeys,
 
---

base-commit: 714d87c90a766e6917f7d69f618b864d350f09d3
change-id: 20250123-sysctl_const-pcmoore-fa14389b8329

Best regards,
--
Ricardo B. Marliere <[email protected]>

maintainer
#3 lore raw
Quoted 16 lines · Ricardo B. Marlière
Quoted 15 lines · Paul Moore
Quoted 12 lines · Ricardo B. Marliere

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows for struct ctl_table to be in read-only memory. Move key_sysctls to be declared at build time, instead of having to be dynamically allocated at boot time.

---
 security/keys/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 8 lines
Quoted 4 lines

Looks fine to me. David or Jarkko, this looks like something for the keys tree, yes?

Thank you for the review, but I believe this has been done here:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1751f872cc97f992ed5c4c72c55588db1f0021e1

Even better :) Thanks for the update Ricardo.

Signature · 1 line
paul-moore.com
maintainer
#4 lore raw
Quoted 20 lines · Paul Moore
Quoted 19 lines · Ricardo B. Marlière
Quoted 18 lines · Paul Moore
Quoted 6 lines · Ricardo B. Marliere

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows for struct ctl_table to be in read-only memory. Move key_sysctls to be declared at build time, instead of having to be dynamically allocated at boot time.

Quoted 6 lines
---
 security/keys/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Looks fine to me. David or Jarkko, this looks like something for the keys tree, yes?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Thank you for the review, but I believe this has been done here:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1751f872cc97f992ed5c4c72c55588db1f0021e1

Even better :) Thanks for the update Ricardo.

+1

BR, Jarkko

maintainer Reviewed-by
#5 lore raw
In reply to Paul Moore
Quoted 15 lines · Paul Moore
Quoted 6 lines · Ricardo B. Marliere

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows for struct ctl_table to be in read-only memory. Move key_sysctls to be declared at build time, instead of having to be dynamically allocated at boot time.

Quoted 6 lines
---
 security/keys/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines

Looks fine to me. David or Jarkko, this looks like something for the keys tree, yes?

I can pick this after back from holiday on next week.

BR, Jarkko