Commit fb1b83d3 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux

Pull module updates from Rusty Russell:
 "The only interesting thing here is Jessica's patch to add
  ro_after_init support to modules.  The rest are all trivia"

* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
  extable.h: add stddef.h so "NULL" definition is not implicit
  modules: add ro_after_init support
  jump_label: disable preemption around __module_text_address().
  exceptions: fork exception table content from module.h into extable.h
  modules: Add kernel parameter to blacklist modules
  module: Do a WARN_ON_ONCE() for assert module mutex not held
  Documentation/module-signing.txt: Note need for version info if reusing a key
  module: Invalidate signatures on force-loaded modules
  module: Issue warnings when tainting kernel
  module: fix redundant test.
  module: fix noreturn attribute for __module_put_and_exit()
parents d597690e 49aadcf1
...@@ -2320,6 +2320,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -2320,6 +2320,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
Note that if CONFIG_MODULE_SIG_FORCE is set, that Note that if CONFIG_MODULE_SIG_FORCE is set, that
is always true, so this option does nothing. is always true, so this option does nothing.
module_blacklist= [KNL] Do not load a comma-separated list of
modules. Useful for debugging problem modules.
mousedev.tap_time= mousedev.tap_time=
[MOUSE] Maximum time between finger touching and [MOUSE] Maximum time between finger touching and
leaving touchpad surface for touch to be considered leaving touchpad surface for touch to be considered
......
...@@ -271,3 +271,9 @@ Since the private key is used to sign modules, viruses and malware could use ...@@ -271,3 +271,9 @@ Since the private key is used to sign modules, viruses and malware could use
the private key to sign modules and compromise the operating system. The the private key to sign modules and compromise the operating system. The
private key must be either destroyed or moved to a secure location and not kept private key must be either destroyed or moved to a secure location and not kept
in the root node of the kernel source tree. in the root node of the kernel source tree.
If you use the same private key to sign modules for multiple kernel
configurations, you must ensure that the module version information is
sufficient to prevent loading a module into a different kernel. Either
set CONFIG_MODVERSIONS=y or ensure that each configuration has a different
kernel release string by changing EXTRAVERSION or CONFIG_LOCALVERSION.
#ifndef _LINUX_EXTABLE_H
#define _LINUX_EXTABLE_H
#include <linux/stddef.h> /* for NULL */
struct module;
struct exception_table_entry;
const struct exception_table_entry *
search_extable(const struct exception_table_entry *first,
const struct exception_table_entry *last,
unsigned long value);
void sort_extable(struct exception_table_entry *start,
struct exception_table_entry *finish);
void sort_main_extable(void);
void trim_init_extable(struct module *m);
/* Given an address, look for it in the exception tables */
const struct exception_table_entry *search_exception_tables(unsigned long add);
#ifdef CONFIG_MODULES
/* For extable.c to search modules' exception tables. */
const struct exception_table_entry *search_module_extables(unsigned long addr);
#else
static inline const struct exception_table_entry *
search_module_extables(unsigned long addr)
{
return NULL;
}
#endif /*CONFIG_MODULES*/
#endif /* _LINUX_EXTABLE_H */
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/jump_label.h> #include <linux/jump_label.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/extable.h> /* only as arch move module.h -> extable.h */
#include <linux/rbtree_latch.h> #include <linux/rbtree_latch.h>
#include <linux/percpu.h> #include <linux/percpu.h>
...@@ -37,6 +38,7 @@ struct modversion_info { ...@@ -37,6 +38,7 @@ struct modversion_info {
}; };
struct module; struct module;
struct exception_table_entry;
struct module_kobject { struct module_kobject {
struct kobject kobj; struct kobject kobj;
...@@ -155,18 +157,6 @@ extern void cleanup_module(void); ...@@ -155,18 +157,6 @@ extern void cleanup_module(void);
#define __INITRODATA_OR_MODULE __INITRODATA #define __INITRODATA_OR_MODULE __INITRODATA
#endif /*CONFIG_MODULES*/ #endif /*CONFIG_MODULES*/
/* Archs provide a method of finding the correct exception table. */
struct exception_table_entry;
const struct exception_table_entry *
search_extable(const struct exception_table_entry *first,
const struct exception_table_entry *last,
unsigned long value);
void sort_extable(struct exception_table_entry *start,
struct exception_table_entry *finish);
void sort_main_extable(void);
void trim_init_extable(struct module *m);
/* Generic info of form tag = "info" */ /* Generic info of form tag = "info" */
#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
...@@ -268,9 +258,6 @@ extern const typeof(name) __mod_##type##__##name##_device_table \ ...@@ -268,9 +258,6 @@ extern const typeof(name) __mod_##type##__##name##_device_table \
* files require multiple MODULE_FIRMWARE() specifiers */ * files require multiple MODULE_FIRMWARE() specifiers */
#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware) #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
/* Given an address, look for it in the exception tables */
const struct exception_table_entry *search_exception_tables(unsigned long add);
struct notifier_block; struct notifier_block;
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
...@@ -311,6 +298,8 @@ struct module_layout { ...@@ -311,6 +298,8 @@ struct module_layout {
unsigned int text_size; unsigned int text_size;
/* Size of RO section of the module (text+rodata) */ /* Size of RO section of the module (text+rodata) */
unsigned int ro_size; unsigned int ro_size;
/* Size of RO after init section */
unsigned int ro_after_init_size;
#ifdef CONFIG_MODULES_TREE_LOOKUP #ifdef CONFIG_MODULES_TREE_LOOKUP
struct mod_tree_node mtn; struct mod_tree_node mtn;
...@@ -575,8 +564,8 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, ...@@ -575,8 +564,8 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
struct module *, unsigned long), struct module *, unsigned long),
void *data); void *data);
extern void __module_put_and_exit(struct module *mod, long code) extern void __noreturn __module_put_and_exit(struct module *mod,
__attribute__((noreturn)); long code);
#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code) #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code)
#ifdef CONFIG_MODULE_UNLOAD #ifdef CONFIG_MODULE_UNLOAD
...@@ -630,9 +619,6 @@ const char *module_address_lookup(unsigned long addr, ...@@ -630,9 +619,6 @@ const char *module_address_lookup(unsigned long addr,
int lookup_module_symbol_name(unsigned long addr, char *symname); int lookup_module_symbol_name(unsigned long addr, char *symname);
int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
/* For extable.c to search modules' exception tables. */
const struct exception_table_entry *search_module_extables(unsigned long addr);
int register_module_notifier(struct notifier_block *nb); int register_module_notifier(struct notifier_block *nb);
int unregister_module_notifier(struct notifier_block *nb); int unregister_module_notifier(struct notifier_block *nb);
...@@ -657,13 +643,6 @@ static inline bool is_livepatch_module(struct module *mod) ...@@ -657,13 +643,6 @@ static inline bool is_livepatch_module(struct module *mod)
#else /* !CONFIG_MODULES... */ #else /* !CONFIG_MODULES... */
/* Given an address, look for it in the exception tables. */
static inline const struct exception_table_entry *
search_module_extables(unsigned long addr)
{
return NULL;
}
static inline struct module *__module_address(unsigned long addr) static inline struct module *__module_address(unsigned long addr)
{ {
return NULL; return NULL;
...@@ -788,12 +767,12 @@ extern int module_sysfs_initialized; ...@@ -788,12 +767,12 @@ extern int module_sysfs_initialized;
#ifdef CONFIG_DEBUG_SET_MODULE_RONX #ifdef CONFIG_DEBUG_SET_MODULE_RONX
extern void set_all_modules_text_rw(void); extern void set_all_modules_text_rw(void);
extern void set_all_modules_text_ro(void); extern void set_all_modules_text_ro(void);
extern void module_enable_ro(const struct module *mod); extern void module_enable_ro(const struct module *mod, bool after_init);
extern void module_disable_ro(const struct module *mod); extern void module_disable_ro(const struct module *mod);
#else #else
static inline void set_all_modules_text_rw(void) { } static inline void set_all_modules_text_rw(void) { }
static inline void set_all_modules_text_ro(void) { } static inline void set_all_modules_text_ro(void) { }
static inline void module_enable_ro(const struct module *mod) { } static inline void module_enable_ro(const struct module *mod, bool after_init) { }
static inline void module_disable_ro(const struct module *mod) { } static inline void module_disable_ro(const struct module *mod) { }
#endif #endif
......
...@@ -286,6 +286,7 @@ typedef struct elf64_phdr { ...@@ -286,6 +286,7 @@ typedef struct elf64_phdr {
#define SHF_ALLOC 0x2 #define SHF_ALLOC 0x2
#define SHF_EXECINSTR 0x4 #define SHF_EXECINSTR 0x4
#define SHF_RELA_LIVEPATCH 0x00100000 #define SHF_RELA_LIVEPATCH 0x00100000
#define SHF_RO_AFTER_INIT 0x00200000
#define SHF_MASKPROC 0xf0000000 #define SHF_MASKPROC 0xf0000000
/* special section indexes */ /* special section indexes */
......
...@@ -337,11 +337,14 @@ static int __jump_label_mod_text_reserved(void *start, void *end) ...@@ -337,11 +337,14 @@ static int __jump_label_mod_text_reserved(void *start, void *end)
{ {
struct module *mod; struct module *mod;
preempt_disable();
mod = __module_text_address((unsigned long)start); mod = __module_text_address((unsigned long)start);
WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
preempt_enable();
if (!mod) if (!mod)
return 0; return 0;
WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
return __jump_label_text_reserved(mod->jump_entries, return __jump_label_text_reserved(mod->jump_entries,
mod->jump_entries + mod->num_jump_entries, mod->jump_entries + mod->num_jump_entries,
......
...@@ -309,7 +309,7 @@ static int klp_write_object_relocations(struct module *pmod, ...@@ -309,7 +309,7 @@ static int klp_write_object_relocations(struct module *pmod,
break; break;
} }
module_enable_ro(pmod); module_enable_ro(pmod, true);
return ret; return ret;
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment