From be16ad6710806650c28b25492349514760ed72c0 Mon Sep 17 00:00:00 2001 From: HJ Pao Date: Wed, 3 Jul 2024 00:50:50 +0800 Subject: [PATCH] Add sudo for file access permissions Add sudo to commands in Chapter 8 for example module interaction. The "myvariables" in the module are set with 0660 permissions via __ATTR(), preventing direct user access. Options to fix this: 1. Instruct users to use 'sudo' to read/write files. 2. Relax the permission settings to 0666. This commit adopts the sudo method to maintain security constraints. --- lkmpg.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lkmpg.tex b/lkmpg.tex index 3024f20..10b3d55 100644 --- a/lkmpg.tex +++ b/lkmpg.tex @@ -1347,14 +1347,14 @@ sudo lsmod | grep hello_sysfs What is the current value of \cpp|myvariable| ? \begin{codebash} -cat /sys/kernel/mymodule/myvariable +sudo cat /sys/kernel/mymodule/myvariable \end{codebash} Set the value of \cpp|myvariable| and check that it changed. \begin{codebash} -echo "32" > /sys/kernel/mymodule/myvariable -cat /sys/kernel/mymodule/myvariable +echo "32" | sudo tee /sys/kernel/mymodule/myvariable +sudo cat /sys/kernel/mymodule/myvariable \end{codebash} Finally, remove the test module: