Re: [PATCH 2/2] LoadPin: Make sysctl table const

From
Kees Cook <kees@kernel.org>
Date
2025-02-11 00:38:32
Also in
lkml
Reply to
Ricardo B. Marliere, 2025-01-23
On Thu, Jan 23, 2025 at 04:33:35PM -0300, Ricardo B. Marliere wrote:
quoted hunk ↗ jump to hunk
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 loadpin_sysctl_table to be declared at build
time, instead of having to be dynamically allocated at boot time.

Cc: Thomas Weißschuh <linux@weissschuh.net>
Suggested-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Ricardo B. Marliere <redacted>
---
 security/loadpin/loadpin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
index 68252452b66cb913638abbca2adea26219e77d37..e2d664b7602629c08c86d6d02158a4e9dd189b1a 100644
--- a/security/loadpin/loadpin.c
+++ b/security/loadpin/loadpin.c
@@ -53,7 +53,7 @@ static bool deny_reading_verity_digests;
 #endif
 
 #ifdef CONFIG_SYSCTL
-static struct ctl_table loadpin_sysctl_table[] = {
+static const struct ctl_table loadpin_sysctl_table[] = {
 	{
 		.procname       = "enforce",
 		.data           = &enforce,
This can't be done since the table is modified during set_sysctl().

-Kees

-- 
Kees Cook
Thread (11 messages) 11 messages, 4 authors, last reply 2025-02-14
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help