1. 14 12月, 2012 2 次提交
    • R
      module: add flags arg to sys_finit_module() · 2f3238ae
      Rusty Russell 提交于
      Thanks to Michael Kerrisk for keeping us honest.  These flags are actually
      useful for eliminating the only case where kmod has to mangle a module's
      internals: for overriding module versioning.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Acked-by: NLucas De Marchi <lucas.demarchi@profusion.mobi>
      Acked-by: NKees Cook <keescook@chromium.org>
      2f3238ae
    • K
      module: add syscall to load module from fd · 34e1169d
      Kees Cook 提交于
      As part of the effort to create a stronger boundary between root and
      kernel, Chrome OS wants to be able to enforce that kernel modules are
      being loaded only from our read-only crypto-hash verified (dm_verity)
      root filesystem. Since the init_module syscall hands the kernel a module
      as a memory blob, no reasoning about the origin of the blob can be made.
      
      Earlier proposals for appending signatures to kernel modules would not be
      useful in Chrome OS, since it would involve adding an additional set of
      keys to our kernel and builds for no good reason: we already trust the
      contents of our root filesystem. We don't need to verify those kernel
      modules a second time. Having to do signature checking on module loading
      would slow us down and be redundant. All we need to know is where a
      module is coming from so we can say yes/no to loading it.
      
      If a file descriptor is used as the source of a kernel module, many more
      things can be reasoned about. In Chrome OS's case, we could enforce that
      the module lives on the filesystem we expect it to live on.  In the case
      of IMA (or other LSMs), it would be possible, for example, to examine
      extended attributes that may contain signatures over the contents of
      the module.
      
      This introduces a new syscall (on x86), similar to init_module, that has
      only two arguments. The first argument is used as a file descriptor to
      the module and the second argument is a pointer to the NULL terminated
      string of module arguments.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (merge fixes)
      34e1169d
  2. 31 10月, 2012 1 次提交
    • R
      module: fix out-by-one error in kallsyms · 59ef28b1
      Rusty Russell 提交于
      Masaki found and patched a kallsyms issue: the last symbol in a
      module's symtab wasn't transferred.  This is because we manually copy
      the zero'th entry (which is always empty) then copy the rest in a loop
      starting at 1, though from src[0].  His fix was minimal, I prefer to
      rewrite the loops in more standard form.
      
      There are two loops: one to get the size, and one to copy.  Make these
      identical: always count entry 0 and any defined symbol in an allocated
      non-init section.
      
      This bug exists since the following commit was introduced.
         module: reduce symbol table for loaded modules (v2)
         commit: 4a496226
      
      LKML: http://lkml.org/lkml/2012/10/24/27Reported-by: NMasaki Kimura <masaki.kimura.kz@hitachi.com>
      Cc: stable@kernel.org
      59ef28b1
  3. 20 10月, 2012 1 次提交
    • D
      MODSIGN: Move the magic string to the end of a module and eliminate the search · caabe240
      David Howells 提交于
      Emit the magic string that indicates a module has a signature after the
      signature data instead of before it.  This allows module_sig_check() to
      be made simpler and faster by the elimination of the search for the
      magic string.  Instead we just need to do a single memcmp().
      
      This works because at the end of the signature data there is the
      fixed-length signature information block.  This block then falls
      immediately prior to the magic number.
      
      From the contents of the information block, it is trivial to calculate
      the size of the signature data and thus the size of the actual module
      data.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      caabe240
  4. 10 10月, 2012 2 次提交
  5. 28 9月, 2012 4 次提交
    • R
      module: wait when loading a module which is currently initializing. · 9bb9c3be
      Rusty Russell 提交于
      The original module-init-tools module loader used a fnctl lock on the
      .ko file to avoid attempts to simultaneously load a module.
      Unfortunately, you can't get an exclusive fcntl lock on a read-only
      fd, making this not work for read-only mounted filesystems.
      module-init-tools has a hacky sleep-and-loop for this now.
      
      It's not that hard to wait in the kernel, and only return -EEXIST once
      the first module has finished loading (or continue loading the module
      if the first one failed to initialize for some reason).  It's also
      consistent with what we do for dependent modules which are still loading.
      Suggested-by: NLucas De Marchi <lucas.demarchi@profusion.mobi>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      9bb9c3be
    • R
      module: fix symbol waiting when module fails before init · 6f13909f
      Rusty Russell 提交于
      We use resolve_symbol_wait(), which blocks if the module containing
      the symbol is still loading.  However:
      
      1) The module_wq we use is only woken after calling the modules' init
         function, but there are other failure paths after the module is
         placed in the linked list where we need to do the same thing.
      
      2) wake_up() only wakes one waiter, and our waitqueue is shared by all
         modules, so we need to wake them all.
      
      3) wake_up_all() doesn't imply a memory barrier: I feel happier calling
         it after we've grabbed and dropped the module_mutex, not just after
         the state assignment.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      6f13909f
    • D
      Make most arch asm/module.h files use asm-generic/module.h · 786d35d4
      David Howells 提交于
      Use the mapping of Elf_[SPE]hdr, Elf_Addr, Elf_Sym, Elf_Dyn, Elf_Rel/Rela,
      ELF_R_TYPE() and ELF_R_SYM() to either the 32-bit version or the 64-bit version
      into asm-generic/module.h for all arches bar MIPS.
      
      Also, use the generic definition mod_arch_specific where possible.
      
      To this end, I've defined three new config bools:
      
       (*) HAVE_MOD_ARCH_SPECIFIC
      
           Arches define this if they don't want to use the empty generic
           mod_arch_specific struct.
      
       (*) MODULES_USE_ELF_RELA
      
           Arches define this if their modules can contain RELA records.  This causes
           the Elf_Rela mapping to be emitted and allows apply_relocate_add() to be
           defined by the arch rather than have the core emit an error message.
      
       (*) MODULES_USE_ELF_REL
      
           Arches define this if their modules can contain REL records.  This causes
           the Elf_Rel mapping to be emitted and allows apply_relocate() to be
           defined by the arch rather than have the core emit an error message.
      
      Note that it is possible to allow both REL and RELA records: m68k and mips are
      two arches that do this.
      
      With this, some arch asm/module.h files can be deleted entirely and replaced
      with a generic-y marker in the arch Kbuild file.
      
      Additionally, I have removed the bits from m32r and score that handle the
      unsupported type of relocation record as that's now handled centrally.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      786d35d4
    • M
      module: taint kernel when lve module is loaded · c99af375
      Matthew Garrett 提交于
      Cloudlinux have a product called lve that includes a kernel module. This
      was previously GPLed but is now under a proprietary license, but the
      module continues to declare MODULE_LICENSE("GPL") and makes use of some
      EXPORT_SYMBOL_GPL symbols. Forcibly taint it in order to avoid this.
      Signed-off-by: NMatthew Garrett <mjg59@srcf.ucam.org>
      Cc: Alex Lyashkov <umka@cloudlinux.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: stable@kernel.org
      c99af375
  6. 23 5月, 2012 1 次提交
  7. 01 5月, 2012 1 次提交
    • J
      dynamic_debug: make dynamic-debug work for module initialization · b48420c1
      Jim Cromie 提交于
      This introduces a fake module param $module.dyndbg.  Its based upon
      Thomas Renninger's $module.ddebug boot-time debugging patch from
      https://lkml.org/lkml/2010/9/15/397
      
      The 'fake' module parameter is provided for all modules, whether or
      not they need it.  It is not explicitly added to each module, but is
      implemented in callbacks invoked from parse_args.
      
      For builtin modules, dynamic_debug_init() now directly calls
      parse_args(..., &ddebug_dyndbg_boot_params_cb), to process the params
      undeclared in the modules, just after the ddebug tables are processed.
      
      While its slightly weird to reprocess the boot params, parse_args() is
      already called repeatedly by do_initcall_levels().  More importantly,
      the dyndbg queries (given in ddebug_query or dyndbg params) cannot be
      activated until after the ddebug tables are ready, and reusing
      parse_args is cleaner than doing an ad-hoc parse.  This reparse would
      break options like inc_verbosity, but they probably should be params,
      like verbosity=3.
      
      ddebug_dyndbg_boot_params_cb() handles both bare dyndbg (aka:
      ddebug_query) and module-prefixed dyndbg params, and ignores all other
      parameters.  For example, the following will enable pr_debug()s in 4
      builtin modules, in the order given:
      
        dyndbg="module params +p; module aio +p" module.dyndbg=+p pci.dyndbg
      
      For loadable modules, parse_args() in load_module() calls
      ddebug_dyndbg_module_params_cb().  This handles bare dyndbg params as
      passed from modprobe, and errors on other unknown params.
      
      Note that modprobe reads /proc/cmdline, so "modprobe foo" grabs all
      foo.params, strips the "foo.", and passes these to the kernel.
      ddebug_dyndbg_module_params_cb() is again called for the unknown
      params; it handles dyndbg, and errors on others.  The "doing" arg
      added previously contains the module name.
      
      For non CONFIG_DYNAMIC_DEBUG builds, the stub function accepts
      and ignores $module.dyndbg params, other unknowns get -ENOENT.
      
      If no param value is given (as in pci.dyndbg example above), "+p" is
      assumed, which enables all pr_debug callsites in the module.
      
      The dyndbg fake parameter is not shown in /sys/module/*/parameters,
      thus it does not use any resources.  Changes to it are made via the
      control file.
      
      Also change pr_info in ddebug_exec_queries to vpr_info,
      no need to see it all the time.
      Signed-off-by: NJim Cromie <jim.cromie@gmail.com>
      CC: Thomas Renninger <trenn@suse.de>
      CC: Rusty Russell <rusty@rustcorp.com.au>
      Acked-by: NJason Baron <jbaron@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b48420c1
  8. 26 3月, 2012 4 次提交
  9. 16 1月, 2012 1 次提交
  10. 13 1月, 2012 5 次提交
  11. 07 11月, 2011 2 次提交
  12. 31 10月, 2011 1 次提交
  13. 11 8月, 2011 1 次提交
    • M
      Tracepoint: Dissociate from module mutex · b75ef8b4
      Mathieu Desnoyers 提交于
      Copy the information needed from struct module into a local module list
      held within tracepoint.c from within the module coming/going notifier.
      
      This vastly simplifies locking of tracepoint registration /
      unregistration, because we don't have to take the module mutex to
      register and unregister tracepoints anymore. Steven Rostedt ran into
      dependency problems related to modules mutex vs kprobes mutex vs ftrace
      mutex vs tracepoint mutex that seems to be hard to fix without removing
      this dependency between tracepoint and module mutex. (note: it should be
      investigated whether kprobes could benefit of being dissociated from the
      modules mutex too.)
      
      This also fixes module handling of tracepoint list iterators, because it
      was expecting the list to be sorted by pointer address. Given we have
      control on our own list now, it's OK to sort this list which has
      tracepoints as its only purpose. The reason why this sorting is required
      is to handle the fact that seq files (and any read() operation from
      user-space) cannot hold the tracepoint mutex across multiple calls, so
      list entries may vanish between calls. With sorting, the tracepoint
      iterator becomes usable even if the list don't contain the exact item
      pointed to by the iterator anymore.
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: NJason Baron <jbaron@redhat.com>
      CC: Ingo Molnar <mingo@elte.hu>
      CC: Lai Jiangshan <laijs@cn.fujitsu.com>
      CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Link: http://lkml.kernel.org/r/20110810191839.GC8525@KrystalSigned-off-by: NSteven Rostedt <rostedt@goodmis.org>
      b75ef8b4
  14. 24 7月, 2011 3 次提交
  15. 19 5月, 2011 7 次提交
  16. 26 4月, 2011 1 次提交
  17. 31 3月, 2011 1 次提交
  18. 23 3月, 2011 1 次提交
    • K
      printk: use %pK for /proc/kallsyms and /proc/modules · 9f36e2c4
      Kees Cook 提交于
      In an effort to reduce kernel address leaks that might be used to help
      target kernel privilege escalation exploits, this patch uses %pK when
      displaying addresses in /proc/kallsyms, /proc/modules, and
      /sys/module/*/sections/*.
      
      Note that this changes %x to %p, so some legitimately 0 values in
      /proc/kallsyms would have changed from 00000000 to "(null)".  To avoid
      this, "(null)" is not used when using the "K" format.  Anything that was
      already successfully parsing "(null)" in addition to full hex digits
      should have no problem with this change.  (Thanks to Joe Perches for the
      suggestion.) Due to the %x to %p, "void *" casts are needed since these
      addresses are already "unsigned long" everywhere internally, due to their
      starting life as ELF section offsets.
      Signed-off-by: NKees Cook <kees.cook@canonical.com>
      Cc: Eugene Teo <eugene@redhat.com>
      Cc: Dan Rosenberg <drosenberg@vsecurity.com>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9f36e2c4
  19. 03 2月, 2011 1 次提交
    • M
      tracepoints: Fix section alignment using pointer array · 65498646
      Mathieu Desnoyers 提交于
      Make the tracepoints more robust, making them solid enough to handle compiler
      changes by not relying on anything based on compiler-specific behavior with
      respect to structure alignment. Implement an approach proposed by David Miller:
      use an array of const pointers to refer to the individual structures, and export
      this pointer array through the linker script rather than the structures per se.
      It will consume 32 extra bytes per tracepoint (24 for structure padding and 8
      for the pointers), but are less likely to break due to compiler changes.
      
      History:
      
      commit 7e066fb8 tracepoints: add DECLARE_TRACE() and DEFINE_TRACE()
      added the aligned(32) type and variable attribute to the tracepoint structures
      to deal with gcc happily aligning statically defined structures on 32-byte
      multiples.
      
      One attempt was to use a 8-byte alignment for tracepoint structures by applying
      both the variable and type attribute to tracepoint structures definitions and
      declarations. It worked fine with gcc 4.5.1, but broke with gcc 4.4.4 and 4.4.5.
      
      The reason is that the "aligned" attribute only specify the _minimum_ alignment
      for a structure, leaving both the compiler and the linker free to align on
      larger multiples. Because tracepoint.c expects the structures to be placed as an
      array within each section, up-alignment cause NULL-pointer exceptions due to the
      extra unexpected padding.
      
      (this patch applies on top of -tip)
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      LKML-Reference: <20110126222622.GA10794@Krystal>
      CC: Frederic Weisbecker <fweisbec@gmail.com>
      CC: Ingo Molnar <mingo@elte.hu>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Andrew Morton <akpm@linux-foundation.org>
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      65498646