Skip to content

Commit

Permalink
kallsyms: make kallsyms_show_value() as generic function
Browse files Browse the repository at this point in the history
This change makes function kallsyms_show_value() as
generic function without dependency on CONFIG_KALLSYMS.

Now module address will be displayed with lsmod and /proc/modules.

Earlier:
=======
/ # insmod  test.ko
/ # lsmod
test 12288 0 - Live 0x0000000000000000 (O)  // No Module Load address
/ #

With change:
==========
/ # insmod test.ko
/ # lsmod
test 12288 0 - Live 0xffff800000fc0000 (O)  // Module address
/ # cat /proc/modules
test 12288 0 - Live 0xffff800000fc0000 (O)

Co-developed-by: Onkarnath <[email protected]>
Signed-off-by: Onkarnath <[email protected]>
Signed-off-by: Maninder Singh <[email protected]>
Reviewed-by: Zhen Lei <[email protected]>
Signed-off-by: Luis Chamberlain <[email protected]>
  • Loading branch information
maninder42 authored and mcgrof committed Jun 8, 2023
1 parent b06e931 commit 0eeaf1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 3 additions & 8 deletions include/linux/kallsyms.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static inline void *dereference_symbol_descriptor(void *ptr)
return ptr;
}

/* How and when do we show kallsyms values? */
extern bool kallsyms_show_value(const struct cred *cred);

#ifdef CONFIG_KALLSYMS
unsigned long kallsyms_sym_address(int idx);
int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long),
Expand Down Expand Up @@ -94,9 +97,6 @@ extern int sprint_backtrace_build_id(char *buffer, unsigned long address);

int lookup_symbol_name(unsigned long addr, char *symname);

/* How and when do we show kallsyms values? */
extern bool kallsyms_show_value(const struct cred *cred);

#else /* !CONFIG_KALLSYMS */

static inline unsigned long kallsyms_lookup_name(const char *name)
Expand Down Expand Up @@ -154,11 +154,6 @@ static inline int lookup_symbol_name(unsigned long addr, char *symname)
return -ERANGE;
}

static inline bool kallsyms_show_value(const struct cred *cred)
{
return false;
}

static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long),
void *data)
{
Expand Down
2 changes: 0 additions & 2 deletions kernel/ksyms_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <linux/kallsyms.h>
#include <linux/security.h>

#ifdef CONFIG_KALLSYMS
static inline int kallsyms_for_perf(void)
{
#ifdef CONFIG_PERF_EVENTS
Expand Down Expand Up @@ -42,4 +41,3 @@ bool kallsyms_show_value(const struct cred *cred)
return false;
}
}
#endif

0 comments on commit 0eeaf1e

Please sign in to comment.