Contributors: 35
Author Tokens Token Proportion Commits Commit Proportion
Rusty Russell 117 15.85% 6 12.00%
Ingo Molnar 111 15.04% 1 2.00%
Robert S Peterson 95 12.87% 1 2.00%
Sergey Senozhatsky 86 11.65% 2 4.00%
Andrew Morton 38 5.15% 3 6.00%
Anders H Kaseorg 29 3.93% 1 2.00%
Stephen Boyd 25 3.39% 2 4.00%
Franck Bui-Huu 24 3.25% 1 2.00%
Zhen Lei 23 3.12% 2 4.00%
Vegard Nossum 21 2.85% 2 4.00%
Keith Owens 20 2.71% 2 4.00%
Alexey Dobriyan 16 2.17% 2 4.00%
Jiri Olsa 15 2.03% 1 2.00%
Heiko Carstens 11 1.49% 2 4.00%
Namhyung Kim 11 1.49% 1 2.00%
Linus Torvalds 11 1.49% 2 4.00%
Matt Domsch 10 1.36% 1 2.00%
Kees Cook 9 1.22% 1 2.00%
Andi Kleen 8 1.08% 1 2.00%
Dmitry Safonov 8 1.08% 1 2.00%
Ard Biesheuvel 7 0.95% 1 2.00%
Kefeng Wang 6 0.81% 1 2.00%
John Levon 6 0.81% 1 2.00%
Arjan van de Ven 4 0.54% 1 2.00%
Masahiro Yamada 4 0.54% 1 2.00%
Arnd Bergmann 4 0.54% 1 2.00%
Mika Kukkonen 3 0.41% 1 2.00%
Kamalesh Babulal 3 0.41% 1 2.00%
Adrian Bunk 3 0.41% 1 2.00%
James Bottomley 3 0.41% 1 2.00%
Adam B. Jerome 2 0.27% 1 2.00%
Stephen Wilson 2 0.27% 1 2.00%
Greg Kroah-Hartman 1 0.14% 1 2.00%
Christophe Leroy 1 0.14% 1 2.00%
Miguel Ojeda Sandonis 1 0.14% 1 2.00%
Total 738 50


/* SPDX-License-Identifier: GPL-2.0 */
/* Rewritten and vastly simplified by Rusty Russell for in-kernel
 * module loader:
 *   Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
 */
#ifndef _LINUX_KALLSYMS_H
#define _LINUX_KALLSYMS_H

#include <linux/errno.h>
#include <linux/buildid.h>
#include <linux/kernel.h>
#include <linux/stddef.h>
#include <linux/mm.h>
#include <linux/module.h>

#include <asm/sections.h>

#define KSYM_NAME_LEN 512
#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s %s]") + \
			(KSYM_NAME_LEN - 1) + \
			2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + \
			(BUILD_ID_SIZE_MAX * 2) + 1)

struct cred;
struct module;

static inline int is_kernel_text(unsigned long addr)
{
	if (__is_kernel_text(addr))
		return 1;
	return in_gate_area_no_mm(addr);
}

static inline int is_kernel(unsigned long addr)
{
	if (__is_kernel(addr))
		return 1;
	return in_gate_area_no_mm(addr);
}

static inline int is_ksym_addr(unsigned long addr)
{
	if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
		return is_kernel(addr);

	return is_kernel_text(addr) || is_kernel_inittext(addr);
}

static inline void *dereference_symbol_descriptor(void *ptr)
{
#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS
	struct module *mod;

	ptr = dereference_kernel_function_descriptor(ptr);
	if (is_ksym_addr((unsigned long)ptr))
		return ptr;

	preempt_disable();
	mod = __module_address((unsigned long)ptr);
	preempt_enable();

	if (mod)
		ptr = dereference_module_function_descriptor(mod, ptr);
#endif
	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),
			    void *data);
int kallsyms_on_each_match_symbol(int (*fn)(void *, unsigned long),
				  const char *name, void *data);

/* Lookup the address for a symbol. Returns 0 if not found. */
unsigned long kallsyms_lookup_name(const char *name);

extern int kallsyms_lookup_size_offset(unsigned long addr,
				  unsigned long *symbolsize,
				  unsigned long *offset);

/* Lookup an address.  modname is set to NULL if it's in the kernel. */
const char *kallsyms_lookup(unsigned long addr,
			    unsigned long *symbolsize,
			    unsigned long *offset,
			    char **modname, char *namebuf);

/* Look up a kernel symbol and return it in a text buffer. */
extern int sprint_symbol(char *buffer, unsigned long address);
extern int sprint_symbol_build_id(char *buffer, unsigned long address);
extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
extern int sprint_backtrace(char *buffer, unsigned long address);
extern int sprint_backtrace_build_id(char *buffer, unsigned long address);

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

#else /* !CONFIG_KALLSYMS */

static inline unsigned long kallsyms_lookup_name(const char *name)
{
	return 0;
}

static inline int kallsyms_lookup_size_offset(unsigned long addr,
					      unsigned long *symbolsize,
					      unsigned long *offset)
{
	return 0;
}

static inline const char *kallsyms_lookup(unsigned long addr,
					  unsigned long *symbolsize,
					  unsigned long *offset,
					  char **modname, char *namebuf)
{
	return NULL;
}

static inline int sprint_symbol(char *buffer, unsigned long addr)
{
	*buffer = '\0';
	return 0;
}

static inline int sprint_symbol_build_id(char *buffer, unsigned long address)
{
	*buffer = '\0';
	return 0;
}

static inline int sprint_symbol_no_offset(char *buffer, unsigned long addr)
{
	*buffer = '\0';
	return 0;
}

static inline int sprint_backtrace(char *buffer, unsigned long addr)
{
	*buffer = '\0';
	return 0;
}

static inline int sprint_backtrace_build_id(char *buffer, unsigned long addr)
{
	*buffer = '\0';
	return 0;
}

static inline int lookup_symbol_name(unsigned long addr, char *symname)
{
	return -ERANGE;
}

static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long),
					  void *data)
{
	return -EOPNOTSUPP;
}

static inline int kallsyms_on_each_match_symbol(int (*fn)(void *, unsigned long),
						const char *name, void *data)
{
	return -EOPNOTSUPP;
}
#endif /*CONFIG_KALLSYMS*/

static inline void print_ip_sym(const char *loglvl, unsigned long ip)
{
	printk("%s[<%px>] %pS\n", loglvl, (void *) ip, (void *) ip);
}

#endif /*_LINUX_KALLSYMS_H*/