diff options
| -rw-r--r-- | include/linux/kallsyms.h | 8 | ||||
| -rw-r--r-- | kernel/kallsyms.c | 8 | ||||
| -rw-r--r-- | kernel/module.c | 20 |
3 files changed, 27 insertions, 9 deletions
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 11dd93e42580..0a777c5216b1 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h | |||
| @@ -14,6 +14,14 @@ | |||
| 14 | #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ | 14 | #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ |
| 15 | 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) | 15 | 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) |
| 16 | 16 | ||
| 17 | /* How and when do we show kallsyms values? */ | ||
| 18 | extern int kallsyms_show_value(void); | ||
| 19 | #ifndef CONFIG_64BIT | ||
| 20 | # define KALLSYM_FMT "%08lx" | ||
| 21 | #else | ||
| 22 | # define KALLSYM_FMT "%016lx" | ||
| 23 | #endif | ||
| 24 | |||
| 17 | struct module; | 25 | struct module; |
| 18 | 26 | ||
| 19 | #ifdef CONFIG_KALLSYMS | 27 | #ifdef CONFIG_KALLSYMS |
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 51b49ed452e4..1e6ae66c6244 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c | |||
| @@ -581,12 +581,6 @@ static void s_stop(struct seq_file *m, void *p) | |||
| 581 | { | 581 | { |
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | #ifndef CONFIG_64BIT | ||
| 585 | # define KALLSYM_FMT "%08lx" | ||
| 586 | #else | ||
| 587 | # define KALLSYM_FMT "%016lx" | ||
| 588 | #endif | ||
| 589 | |||
| 590 | static int s_show(struct seq_file *m, void *p) | 584 | static int s_show(struct seq_file *m, void *p) |
| 591 | { | 585 | { |
| 592 | unsigned long value; | 586 | unsigned long value; |
| @@ -640,7 +634,7 @@ static inline int kallsyms_for_perf(void) | |||
| 640 | * Otherwise, require CAP_SYSLOG (assuming kptr_restrict isn't set to | 634 | * Otherwise, require CAP_SYSLOG (assuming kptr_restrict isn't set to |
| 641 | * block even that). | 635 | * block even that). |
| 642 | */ | 636 | */ |
| 643 | static int kallsyms_show_value(void) | 637 | int kallsyms_show_value(void) |
| 644 | { | 638 | { |
| 645 | switch (kptr_restrict) { | 639 | switch (kptr_restrict) { |
| 646 | case 0: | 640 | case 0: |
diff --git a/kernel/module.c b/kernel/module.c index fdb3a6aca363..0122747ba150 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -4147,6 +4147,7 @@ static int m_show(struct seq_file *m, void *p) | |||
| 4147 | { | 4147 | { |
| 4148 | struct module *mod = list_entry(p, struct module, list); | 4148 | struct module *mod = list_entry(p, struct module, list); |
| 4149 | char buf[MODULE_FLAGS_BUF_SIZE]; | 4149 | char buf[MODULE_FLAGS_BUF_SIZE]; |
| 4150 | unsigned long value; | ||
| 4150 | 4151 | ||
| 4151 | /* We always ignore unformed modules. */ | 4152 | /* We always ignore unformed modules. */ |
| 4152 | if (mod->state == MODULE_STATE_UNFORMED) | 4153 | if (mod->state == MODULE_STATE_UNFORMED) |
| @@ -4162,7 +4163,8 @@ static int m_show(struct seq_file *m, void *p) | |||
| 4162 | mod->state == MODULE_STATE_COMING ? "Loading" : | 4163 | mod->state == MODULE_STATE_COMING ? "Loading" : |
| 4163 | "Live"); | 4164 | "Live"); |
| 4164 | /* Used by oprofile and other similar tools. */ | 4165 | /* Used by oprofile and other similar tools. */ |
| 4165 | seq_printf(m, " 0x%pK", mod->core_layout.base); | 4166 | value = m->private ? 0 : (unsigned long)mod->core_layout.base; |
| 4167 | seq_printf(m, " 0x" KALLSYM_FMT, value); | ||
| 4166 | 4168 | ||
| 4167 | /* Taints info */ | 4169 | /* Taints info */ |
| 4168 | if (mod->taints) | 4170 | if (mod->taints) |
| @@ -4184,9 +4186,23 @@ static const struct seq_operations modules_op = { | |||
| 4184 | .show = m_show | 4186 | .show = m_show |
| 4185 | }; | 4187 | }; |
| 4186 | 4188 | ||
| 4189 | /* | ||
| 4190 | * This also sets the "private" pointer to non-NULL if the | ||
| 4191 | * kernel pointers should be hidden (so you can just test | ||
| 4192 | * "m->private" to see if you should keep the values private). | ||
| 4193 | * | ||
| 4194 | * We use the same logic as for /proc/kallsyms. | ||
| 4195 | */ | ||
| 4187 | static int modules_open(struct inode *inode, struct file *file) | 4196 | static int modules_open(struct inode *inode, struct file *file) |
| 4188 | { | 4197 | { |
| 4189 | return seq_open(file, &modules_op); | 4198 | int err = seq_open(file, &modules_op); |
| 4199 | |||
| 4200 | if (!err) { | ||
| 4201 | struct seq_file *m = file->private_data; | ||
| 4202 | m->private = kallsyms_show_value() ? NULL : (void *)8ul; | ||
| 4203 | } | ||
| 4204 | |||
| 4205 | return 0; | ||
| 4190 | } | 4206 | } |
| 4191 | 4207 | ||
| 4192 | static const struct file_operations proc_modules_operations = { | 4208 | static const struct file_operations proc_modules_operations = { |
