1. 18 12月, 2017 1 次提交
    • T
      binder: fix proc->files use-after-free · 7f3dc008
      Todd Kjos 提交于
      proc->files cleanup is initiated by binder_vma_close. Therefore
      a reference on the binder_proc is not enough to prevent the
      files_struct from being released while the binder_proc still has
      a reference. This can lead to an attempt to dereference the
      stale pointer obtained from proc->files prior to proc->files
      cleanup. This has been seen once in task_get_unused_fd_flags()
      when __alloc_fd() is called with a stale "files".
      
      The fix is to protect proc->files with a mutex to prevent cleanup
      while in use.
      Signed-off-by: NTodd Kjos <tkjos@google.com>
      Cc: stable <stable@vger.kernel.org> # 4.14
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f3dc008
  2. 28 11月, 2017 1 次提交
  3. 31 10月, 2017 1 次提交
    • K
      treewide: Fix function prototypes for module_param_call() · e4dca7b7
      Kees Cook 提交于
      Several function prototypes for the set/get functions defined by
      module_param_call() have a slightly wrong argument types. This fixes
      those in an effort to clean up the calls when running under type-enforced
      compiler instrumentation for CFI. This is the result of running the
      following semantic patch:
      
      @match_module_param_call_function@
      declarer name module_param_call;
      identifier _name, _set_func, _get_func;
      expression _arg, _mode;
      @@
      
       module_param_call(_name, _set_func, _get_func, _arg, _mode);
      
      @fix_set_prototype
       depends on match_module_param_call_function@
      identifier match_module_param_call_function._set_func;
      identifier _val, _param;
      type _val_type, _param_type;
      @@
      
       int _set_func(
      -_val_type _val
      +const char * _val
       ,
      -_param_type _param
      +const struct kernel_param * _param
       ) { ... }
      
      @fix_get_prototype
       depends on match_module_param_call_function@
      identifier match_module_param_call_function._get_func;
      identifier _val, _param;
      type _val_type, _param_type;
      @@
      
       int _get_func(
      -_val_type _val
      +char * _val
       ,
      -_param_type _param
      +const struct kernel_param * _param
       ) { ... }
      
      Two additional by-hand changes are included for places where the above
      Coccinelle script didn't notice them:
      
      	drivers/platform/x86/thinkpad_acpi.c
      	fs/lockd/svc.c
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NJessica Yu <jeyu@kernel.org>
      e4dca7b7
  4. 20 10月, 2017 2 次提交
  5. 04 10月, 2017 1 次提交
    • T
      binder: fix use-after-free in binder_transaction() · 512cf465
      Todd Kjos 提交于
      User-space normally keeps the node alive when creating a transaction
      since it has a reference to the target. The local strong ref keeps it
      alive if the sending process dies before the target process processes
      the transaction. If the source process is malicious or has a reference
      counting bug, this can fail.
      
      In this case, when we attempt to decrement the node in the failure
      path, the node has already been freed.
      
      This is fixed by taking a tmpref on the node while constructing
      the transaction. To avoid re-acquiring the node lock and inner
      proc lock to increment the proc's tmpref, a helper is used that
      does the ref increments on both the node and proc.
      Signed-off-by: NTodd Kjos <tkjos@google.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      512cf465
  6. 18 9月, 2017 3 次提交
    • X
      binder: fix memory corruption in binder_transaction binder · d53bebdf
      Xu YiPing 提交于
      commit 7a4408c6 ("binder: make sure accesses to proc/thread are
      safe") made a change to enqueue tcomplete to thread->todo before
      enqueuing the transaction. However, in err_dead_proc_or_thread case,
      the tcomplete is directly freed, without dequeued. It may cause the
      thread->todo list to be corrupted.
      
      So, dequeue it before freeing.
      
      Fixes: 7a4408c6 ("binder: make sure accesses to proc/thread are safe")
      Signed-off-by: NXu YiPing <xuyiping@hisilicon.com>
      Signed-off-by: NTodd Kjos <tkjos@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d53bebdf
    • X
      binder: fix an ret value override · 52b81611
      Xu YiPing 提交于
      commit 372e3147 ("binder: guarantee txn complete / errors delivered
      in-order") incorrectly defined a local ret value.  This ret value will
      be invalid when out of the if block
      
      Fixes: 372e3147 ("binder: refactor binder ref inc/dec for thread safety")
      Signed-off-by: NXu YiPing <xuyiping@hislicon.com>
      Signed-off-by: NTodd Kjos <tkjos@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52b81611
    • A
      android: binder: fix type mismatch warning · 1c363eae
      Arnd Bergmann 提交于
      Allowing binder to expose the 64-bit API on 32-bit kernels caused a
      build warning:
      
      drivers/android/binder.c: In function 'binder_transaction_buffer_release':
      drivers/android/binder.c:2220:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
          fd_array = (u32 *)(parent_buffer + fda->parent_offset);
                     ^
      drivers/android/binder.c: In function 'binder_translate_fd_array':
      drivers/android/binder.c:2445:13: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        fd_array = (u32 *)(parent_buffer + fda->parent_offset);
                   ^
      drivers/android/binder.c: In function 'binder_fixup_parent':
      drivers/android/binder.c:2511:18: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
      
      This adds extra type casts to avoid the warning.
      
      However, there is another problem with the Kconfig option: turning
      it on or off creates two incompatible ABI versions, a kernel that
      has this enabled cannot run user space that was built without it
      or vice versa. A better solution might be to leave the option hidden
      until the binder code is fixed to deal with both ABI versions.
      
      Fixes: e8d2ed7d ("Revert "staging: Fix build issues with new binder API"")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c363eae
  7. 01 9月, 2017 7 次提交
  8. 28 8月, 2017 2 次提交
    • S
      android: binder: Add global lru shrinker to binder · f2517eb7
      Sherry Yang 提交于
      Hold on to the pages allocated and mapped for transaction
      buffers until the system is under memory pressure. When
      that happens, use linux shrinker to free pages. Without
      using shrinker, patch "android: binder: Move buffer out
      of area shared with user space" will cause a significant
      slow down for small transactions that fit into the first
      page because free list buffer header used to be inlined
      with buffer data.
      
      In addition to prevent the performance regression for
      small transactions, this patch improves the performance
      for transactions that take up more than one page.
      
      Modify alloc selftest to work with the shrinker change.
      
      Test: Run memory intensive applications (Chrome and Camera)
      to trigger shrinker callbacks. Binder frees memory as expected.
      Test: Run binderThroughputTest with high memory pressure
      option enabled.
      Signed-off-by: NSherry Yang <sherryy@android.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2517eb7
    • S
      android: binder: Add allocator selftest · 4175e2b4
      Sherry Yang 提交于
      binder_alloc_selftest tests that alloc_new_buf handles page allocation and
      deallocation properly when allocate and free buffers. The test allocates 5
      buffers of various sizes to cover all possible page alignment cases, and
      frees the buffers using a list of exhaustive freeing order.
      
      Test: boot the device with ANDROID_BINDER_IPC_SELFTEST config option
      enabled. Allocator selftest passes.
      Signed-off-by: NSherry Yang <sherryy@android.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4175e2b4
  9. 23 8月, 2017 3 次提交
  10. 17 7月, 2017 19 次提交