forked from mirrors/linux
		
	Some #ifdef CONFIG_KASAN checks are only relevant for software KASAN modes (either related to shadow memory or compiler instrumentation). Expand those into CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS. Link: https://lkml.kernel.org/r/e6971e432dbd72bb897ff14134ebb7e169bdcf0c.1606161801.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Alexander Potapenko <glider@google.com> Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Branislav Rankov <Branislav.Rankov@arm.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Evgenii Stepanov <eugenis@google.com> Cc: Kevin Brodsky <kevin.brodsky@arm.com> Cc: Marco Elver <elver@google.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
		
			
				
	
	
		
			107 lines
		
	
	
	
		
			3.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
	
		
			3.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/* SPDX-License-Identifier: GPL-2.0 */
 | 
						|
#ifndef _LINUX_MODULELOADER_H
 | 
						|
#define _LINUX_MODULELOADER_H
 | 
						|
/* The stuff needed for archs to support modules. */
 | 
						|
 | 
						|
#include <linux/module.h>
 | 
						|
#include <linux/elf.h>
 | 
						|
 | 
						|
/* These may be implemented by architectures that need to hook into the
 | 
						|
 * module loader code.  Architectures that don't need to do anything special
 | 
						|
 * can just rely on the 'weak' default hooks defined in kernel/module.c.
 | 
						|
 * Note, however, that at least one of apply_relocate or apply_relocate_add
 | 
						|
 * must be implemented by each architecture.
 | 
						|
 */
 | 
						|
 | 
						|
/* Adjust arch-specific sections.  Return 0 on success.  */
 | 
						|
int module_frob_arch_sections(Elf_Ehdr *hdr,
 | 
						|
			      Elf_Shdr *sechdrs,
 | 
						|
			      char *secstrings,
 | 
						|
			      struct module *mod);
 | 
						|
 | 
						|
/* Additional bytes needed by arch in front of individual sections */
 | 
						|
unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
 | 
						|
 | 
						|
/* Allocator used for allocating struct module, core sections and init
 | 
						|
   sections.  Returns NULL on failure. */
 | 
						|
void *module_alloc(unsigned long size);
 | 
						|
 | 
						|
/* Free memory returned from module_alloc. */
 | 
						|
void module_memfree(void *module_region);
 | 
						|
 | 
						|
/* Determines if the section name is an init section (that is only used during
 | 
						|
 * module loading).
 | 
						|
 */
 | 
						|
bool module_init_section(const char *name);
 | 
						|
 | 
						|
/* Determines if the section name is an exit section (that is only used during
 | 
						|
 * module unloading)
 | 
						|
 */
 | 
						|
bool module_exit_section(const char *name);
 | 
						|
 | 
						|
/*
 | 
						|
 * Apply the given relocation to the (simplified) ELF.  Return -error
 | 
						|
 * or 0.
 | 
						|
 */
 | 
						|
#ifdef CONFIG_MODULES_USE_ELF_REL
 | 
						|
int apply_relocate(Elf_Shdr *sechdrs,
 | 
						|
		   const char *strtab,
 | 
						|
		   unsigned int symindex,
 | 
						|
		   unsigned int relsec,
 | 
						|
		   struct module *mod);
 | 
						|
#else
 | 
						|
static inline int apply_relocate(Elf_Shdr *sechdrs,
 | 
						|
				 const char *strtab,
 | 
						|
				 unsigned int symindex,
 | 
						|
				 unsigned int relsec,
 | 
						|
				 struct module *me)
 | 
						|
{
 | 
						|
	printk(KERN_ERR "module %s: REL relocation unsupported\n",
 | 
						|
	       module_name(me));
 | 
						|
	return -ENOEXEC;
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
/*
 | 
						|
 * Apply the given add relocation to the (simplified) ELF.  Return
 | 
						|
 * -error or 0
 | 
						|
 */
 | 
						|
#ifdef CONFIG_MODULES_USE_ELF_RELA
 | 
						|
int apply_relocate_add(Elf_Shdr *sechdrs,
 | 
						|
		       const char *strtab,
 | 
						|
		       unsigned int symindex,
 | 
						|
		       unsigned int relsec,
 | 
						|
		       struct module *mod);
 | 
						|
#else
 | 
						|
static inline int apply_relocate_add(Elf_Shdr *sechdrs,
 | 
						|
				     const char *strtab,
 | 
						|
				     unsigned int symindex,
 | 
						|
				     unsigned int relsec,
 | 
						|
				     struct module *me)
 | 
						|
{
 | 
						|
	printk(KERN_ERR "module %s: REL relocation unsupported\n",
 | 
						|
	       module_name(me));
 | 
						|
	return -ENOEXEC;
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
/* Any final processing of module before access.  Return -error or 0. */
 | 
						|
int module_finalize(const Elf_Ehdr *hdr,
 | 
						|
		    const Elf_Shdr *sechdrs,
 | 
						|
		    struct module *mod);
 | 
						|
 | 
						|
/* Any cleanup needed when module leaves. */
 | 
						|
void module_arch_cleanup(struct module *mod);
 | 
						|
 | 
						|
/* Any cleanup before freeing mod->module_init */
 | 
						|
void module_arch_freeing_init(struct module *mod);
 | 
						|
 | 
						|
#if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \
 | 
						|
		!defined(CONFIG_KASAN_VMALLOC)
 | 
						|
#include <linux/kasan.h>
 | 
						|
#define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
 | 
						|
#else
 | 
						|
#define MODULE_ALIGN PAGE_SIZE
 | 
						|
#endif
 | 
						|
 | 
						|
#endif
 |