Skip to content
Snippets Groups Projects
Commit 2cfaa84e authored by Kees Cook's avatar Kees Cook
Browse files

LoadPin: Move pin reporting cleanly out of locking


Refactor the pin reporting to be more cleanly outside the locking. It
was already, but moving it around helps clear the path for the root to
switch when not enforcing.

Cc: Paul Moore <paul@paul-moore.com>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-security-module@vger.kernel.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarSerge Hallyn <serge@hallyn.com>
Link: https://lore.kernel.org/r/20221209195746.1366607-3-keescook@chromium.org
parent 60ba1028
No related branches found
No related tags found
No related merge requests found
...@@ -131,6 +131,7 @@ static int loadpin_check(struct file *file, enum kernel_read_file_id id) ...@@ -131,6 +131,7 @@ static int loadpin_check(struct file *file, enum kernel_read_file_id id)
{ {
struct super_block *load_root; struct super_block *load_root;
const char *origin = kernel_read_file_id_str(id); const char *origin = kernel_read_file_id_str(id);
bool first_root_pin = false;
bool load_root_writable; bool load_root_writable;
/* If the file id is excluded, ignore the pinning. */ /* If the file id is excluded, ignore the pinning. */
...@@ -162,18 +163,14 @@ static int loadpin_check(struct file *file, enum kernel_read_file_id id) ...@@ -162,18 +163,14 @@ static int loadpin_check(struct file *file, enum kernel_read_file_id id)
*/ */
if (!pinned_root) { if (!pinned_root) {
pinned_root = load_root; pinned_root = load_root;
/* first_root_pin = true;
* Unlock now since it's only pinned_root we care about. }
* In the worst case, we will (correctly) report pinning spin_unlock(&pinned_root_spinlock);
* failures before we have announced that pinning is
* enforcing. This would be purely cosmetic. if (first_root_pin) {
*/
spin_unlock(&pinned_root_spinlock);
report_writable(pinned_root, load_root_writable); report_writable(pinned_root, load_root_writable);
set_sysctl(load_root_writable); set_sysctl(load_root_writable);
report_load(origin, file, "pinned"); report_load(origin, file, "pinned");
} else {
spin_unlock(&pinned_root_spinlock);
} }
if (IS_ERR_OR_NULL(pinned_root) || if (IS_ERR_OR_NULL(pinned_root) ||
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment