1. 19 8月, 2016 1 次提交
  2. 30 4月, 2016 1 次提交
    • M
      livepatch: make object/func-walking helpers more robust · f09d9086
      Miroslav Benes 提交于
      Current object-walking helper checks the presence of obj->funcs to
      determine the end of objs array in klp_object structure. This is
      somewhat fragile because one can easily forget about funcs definition
      during livepatch creation. In such a case the livepatch module is
      successfully loaded and all objects after the incorrect one are omitted.
      This is very confusing. Let's make the helper more robust and check also
      for the other external member, name. Thus the helper correctly stops on
      an empty item of the array. We need to have a check for obj->funcs in
      klp_init_object() to make it work.
      
      The same applies to a func-walking helper.
      
      As a benefit we'll check for new_func member definition during the
      livepatch initialization. There is no such check anywhere in the code
      now.
      
      [jkosina@suse.cz: fix shortlog]
      Signed-off-by: NMiroslav Benes <mbenes@suse.cz>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: NJessica Yu <jeyu@redhat.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      f09d9086
  3. 01 4月, 2016 1 次提交
    • J
      livepatch: reuse module loader code to write relocations · 425595a7
      Jessica Yu 提交于
      Reuse module loader code to write relocations, thereby eliminating the need
      for architecture specific relocation code in livepatch. Specifically, reuse
      the apply_relocate_add() function in the module loader to write relocations
      instead of duplicating functionality in livepatch's arch-dependent
      klp_write_module_reloc() function.
      
      In order to accomplish this, livepatch modules manage their own relocation
      sections (marked with the SHF_RELA_LIVEPATCH section flag) and
      livepatch-specific symbols (marked with SHN_LIVEPATCH symbol section
      index). To apply livepatch relocation sections, livepatch symbols
      referenced by relocs are resolved and then apply_relocate_add() is called
      to apply those relocations.
      
      In addition, remove x86 livepatch relocation code and the s390
      klp_write_module_reloc() function stub. They are no longer needed since
      relocation work has been offloaded to module loader.
      
      Lastly, mark the module as a livepatch module so that the module loader
      canappropriately identify and initialize it.
      Signed-off-by: NJessica Yu <jeyu@redhat.com>
      Reviewed-by: NMiroslav Benes <mbenes@suse.cz>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>   # for s390 changes
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      425595a7
  4. 17 3月, 2016 1 次提交
  5. 07 3月, 2016 1 次提交
  6. 04 12月, 2015 2 次提交
    • C
      livepatch: add sympos as disambiguator field to klp_reloc · 064c89df
      Chris J Arges 提交于
      In cases of duplicate symbols, sympos will be used to disambiguate instead
      of val. By default sympos will be 0, and patching will only succeed if
      the symbol is unique. Specifying a positive value will ensure that
      occurrence of the symbol in kallsyms for the patched object will be used
      for patching if it is valid. For external relocations sympos is not
      supported.
      
      Remove klp_verify_callback, klp_verify_args and klp_verify_vmlinux_symbol
      as they are no longer used.
      
      From the klp_reloc structure remove val, as it can be refactored as a
      local variable in klp_write_object_relocations.
      Signed-off-by: NChris J Arges <chris.j.arges@canonical.com>
      Reviewed-by: NPetr Mladek <pmladek@suse.com>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      064c89df
    • C
      livepatch: add old_sympos as disambiguator field to klp_func · b2b018ef
      Chris J Arges 提交于
      Currently, patching objects with duplicate symbol names fail because the
      creation of the sysfs function directory collides with the previous
      attempt. Appending old_addr to the function name is problematic as it
      reveals the address of the function being patch to a normal user. Using
      the symbol's occurrence in kallsyms to postfix the function name in the
      sysfs directory solves the issue of having consistent unique names and
      ensuring that the address is not exposed to a normal user.
      
      In addition, using the symbol position as the user's method to disambiguate
      symbols instead of addr allows for disambiguating symbols in modules as
      well for both function addresses and for relocs. This also simplifies much
      of the code. Special handling for kASLR is no longer needed and can be
      removed. The klp_find_verify_func_addr function can be replaced by
      klp_find_object_symbol, and klp_verify_vmlinux_symbol and its callback can
      be removed completely.
      
      In cases of duplicate symbols, old_sympos will be used to disambiguate
      instead of old_addr. By default old_sympos will be 0, and patching will
      only succeed if the symbol is unique. Specifying a positive value will
      ensure that occurrence of the symbol in kallsyms for the patched object
      will be used for patching if it is valid.
      
      In addition, make old_addr an internal structure field not to be specified
      by the user. Finally, remove klp_find_verify_func_addr as it can be
      replaced by klp_find_object_symbol directly.
      
      Support for symbol position disambiguation for relocations is added in the
      next patch in this series.
      Signed-off-by: NChris J Arges <chris.j.arges@canonical.com>
      Reviewed-by: NPetr Mladek <pmladek@suse.com>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      b2b018ef
  7. 20 5月, 2015 2 次提交
  8. 19 2月, 2015 1 次提交
  9. 04 2月, 2015 1 次提交
  10. 21 1月, 2015 1 次提交
    • J
      livepatch: support for repatching a function · 3c33f5b9
      Josh Poimboeuf 提交于
      Add support for patching a function multiple times.  If multiple patches
      affect a function, the function in the most recently enabled patch
      "wins".  This enables a cumulative patch upgrade path, where each patch
      is a superset of previous patches.
      
      This requires restructuring the data a little bit.  With the current
      design, where each klp_func struct has its own ftrace_ops, we'd have to
      unregister the old ops and then register the new ops, because
      FTRACE_OPS_FL_IPMODIFY prevents us from having two ops registered for
      the same function at the same time.  That would leave a regression
      window where the function isn't patched at all (not good for a patch
      upgrade path).
      
      This patch replaces the per-klp_func ftrace_ops with a global klp_ops
      list, with one ftrace_ops per original function.  A single ftrace_ops is
      shared between all klp_funcs which have the same old_addr.  This allows
      the switch between function versions to happen instantaneously by
      updating the klp_ops struct's func_stack list.  The winner is the
      klp_func at the top of the func_stack (front of the list).
      
      [ jkosina@suse.cz: turn WARN_ON() into WARN_ON_ONCE() in ftrace handler to
        avoid storm in pathological cases ]
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Reviewed-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      3c33f5b9
  11. 22 12月, 2014 1 次提交