hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/security/loadpin/loadpin.c
....@@ -118,20 +118,10 @@
118118 }
119119 }
120120
121
-static int loadpin_read_file(struct file *file, enum kernel_read_file_id id,
122
- bool contents)
121
+static int loadpin_check(struct file *file, enum kernel_read_file_id id)
123122 {
124123 struct super_block *load_root;
125124 const char *origin = kernel_read_file_id_str(id);
126
-
127
- /*
128
- * If we will not know that we'll be seeing the full contents
129
- * then we cannot trust a load will be complete and unchanged
130
- * off disk. Treat all contents=false hooks as if there were
131
- * no associated file struct.
132
- */
133
- if (!contents)
134
- file = NULL;
135125
136126 /* If the file id is excluded, ignore the pinning. */
137127 if ((unsigned int)id < ARRAY_SIZE(ignore_read_file_id) &&
....@@ -187,9 +177,25 @@
187177 return 0;
188178 }
189179
180
+static int loadpin_read_file(struct file *file, enum kernel_read_file_id id,
181
+ bool contents)
182
+{
183
+ /*
184
+ * LoadPin only cares about the _origin_ of a file, not its
185
+ * contents, so we can ignore the "are full contents available"
186
+ * argument here.
187
+ */
188
+ return loadpin_check(file, id);
189
+}
190
+
190191 static int loadpin_load_data(enum kernel_load_data_id id, bool contents)
191192 {
192
- return loadpin_read_file(NULL, (enum kernel_read_file_id) id, contents);
193
+ /*
194
+ * LoadPin only cares about the _origin_ of a file, not its
195
+ * contents, so a NULL file is passed, and we can ignore the
196
+ * state of "contents".
197
+ */
198
+ return loadpin_check(NULL, (enum kernel_read_file_id) id);
193199 }
194200
195201 static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = {