hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/kernel/trace/trace_printk.c
....@@ -6,6 +6,7 @@
66 *
77 */
88 #include <linux/seq_file.h>
9
+#include <linux/security.h>
910 #include <linux/uaccess.h>
1011 #include <linux/kernel.h>
1112 #include <linux/ftrace.h>
....@@ -95,7 +96,7 @@
9596 if (val == MODULE_STATE_COMING)
9697 hold_module_trace_bprintk_format(start, end);
9798 }
98
- return 0;
99
+ return NOTIFY_OK;
99100 }
100101
101102 /*
....@@ -115,7 +116,7 @@
115116 * section, then we need to read the link list pointers. The trick is
116117 * we pass the address of the string to the seq function just like
117118 * we do for the kernel core formats. To get back the structure that
118
- * holds the format, we simply use containerof() and then go to the
119
+ * holds the format, we simply use container_of() and then go to the
119120 * next format in the list.
120121 */
121122 static const char **
....@@ -173,7 +174,7 @@
173174 module_trace_bprintk_format_notify(struct notifier_block *self,
174175 unsigned long val, void *data)
175176 {
176
- return 0;
177
+ return NOTIFY_OK;
177178 }
178179 static inline const char **
179180 find_next_mod_format(int start_index, void *v, const char **fmt, loff_t *pos)
....@@ -305,7 +306,7 @@
305306 if (!*fmt)
306307 return 0;
307308
308
- seq_printf(m, "0x%lx : \"", 0L);
309
+ seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt);
309310
310311 /*
311312 * Tabs and new lines need to be converted.
....@@ -348,6 +349,12 @@
348349 static int
349350 ftrace_formats_open(struct inode *inode, struct file *file)
350351 {
352
+ int ret;
353
+
354
+ ret = security_locked_down(LOCKDOWN_TRACEFS);
355
+ if (ret)
356
+ return ret;
357
+
351358 return seq_open(file, &show_format_seq_ops);
352359 }
353360
....@@ -360,13 +367,13 @@
360367
361368 static __init int init_trace_printk_function_export(void)
362369 {
363
- struct dentry *d_tracer;
370
+ int ret;
364371
365
- d_tracer = tracing_init_dentry();
366
- if (IS_ERR(d_tracer))
372
+ ret = tracing_init_dentry();
373
+ if (ret)
367374 return 0;
368375
369
- trace_create_file("printk_formats", 0444, d_tracer,
376
+ trace_create_file("printk_formats", 0444, NULL,
370377 NULL, &ftrace_formats_fops);
371378
372379 return 0;