Skip to content

Commit

Permalink
Add sudo for file access permissions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pao0626 committed Jul 3, 2024
1 parent 1d3943a commit be16ad6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lkmpg.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1347,14 +1347,14 @@ \section{sysfs: Interacting with your module}
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:
Expand Down

0 comments on commit be16ad6

Please sign in to comment.