Re: [PATCH] loadpin: Implement custom proc_handler for enforce

From
Joel Granados <joel.granados@kernel.org>
Date
2025-12-19 10:55:14
Also in
lkml
Reply to
Kees Cook, 2025-12-16
Sent out a V2

On Tue, Dec 16, 2025 at 12:37:29AM -0800, Kees Cook wrote:
On Mon, Dec 15, 2025 at 04:43:48PM +0100, Joel Granados wrote:
quoted
The new proc_handler_loadpin returns -EINVAL when is_loadpin_writable is
false and the kernel var (enforce) is being written. Move
loadpin_sysctl_table to .rodata (by const qualifying it) as there is no
need to change the value of the extra1 entry.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
Const qualifying ctl tables is part of the hardening effort in the linux
kernel.
Ah yes, thanks for getting through these "weird" cases! :)
quoted
---
 security/loadpin/loadpin.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
index 273ffbd6defe1324d6688dec5f9fe6c9401283ed..f049c81b82a78265b6ae358bb2a814265cec9f16 100644
--- a/security/loadpin/loadpin.c
+++ b/security/loadpin/loadpin.c
@@ -53,18 +53,29 @@ static bool deny_reading_verity_digests;
 #endif
 
 #ifdef CONFIG_SYSCTL
-static struct ctl_table loadpin_sysctl_table[] = {
+static bool is_loadpin_writable;
I would rather that load_root_writable were declared external to
loadpin_check(), and then we could remove set_sysctl() entirely, instead
using load_root_writable as the thing to check in proc_handler_loadpin().

And also rename load_root_writable to "loadpin_root_writable", just to
make it a bit more clear.

-Kees

-- 
Kees Cook
-- 

Joel Granados

Attachments

Thread (4 messages) 4 messages, 2 authors, last reply 2025-12-19
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