Skip to content
Snippets Groups Projects
  1. Dec 05, 2018
    • Todd Kjos's avatar
      binder: fix race that allows malicious free of live buffer · fd6cc33d
      Todd Kjos authored
      
      commit 7bada55a upstream.
      
      Malicious code can attempt to free buffers using the BC_FREE_BUFFER
      ioctl to binder. There are protections against a user freeing a buffer
      while in use by the kernel, however there was a window where
      BC_FREE_BUFFER could be used to free a recently allocated buffer that
      was not completely initialized. This resulted in a use-after-free
      detected by KASAN with a malicious test program.
      
      This window is closed by setting the buffer's allow_user_free attribute
      to 0 when the buffer is allocated or when the user has previously freed
      it instead of waiting for the caller to set it. The problem was that
      when the struct buffer was recycled, allow_user_free was stale and set
      to 1 allowing a free to go through.
      
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Acked-by: default avatarArve Hjønnevåg <arve@android.com>
      Cc: stable <stable@vger.kernel.org> # 4.14
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      fd6cc33d
  2. Oct 21, 2017
  3. Sep 01, 2017
  4. Aug 28, 2017
    • Sherry Yang's avatar
      android: binder: Add global lru shrinker to binder · f2517eb7
      Sherry Yang authored
      
      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: default avatarSherry Yang <sherryy@android.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2517eb7
    • Sherry Yang's avatar
      android: binder: Move buffer out of area shared with user space · 74310e06
      Sherry Yang authored
      
      Binder driver allocates buffer meta data in a region that is mapped
      in user space. These meta data contain pointers in the kernel.
      
      This patch allocates buffer meta data on the kernel heap that is
      not mapped in user space, and uses a pointer to refer to the data mapped.
      
      Signed-off-by: default avatarSherry Yang <sherryy@android.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      74310e06
    • Sherry Yang's avatar
      android: binder: Add allocator selftest · 4175e2b4
      Sherry Yang authored
      
      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: default avatarSherry Yang <sherryy@android.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4175e2b4
  5. Jul 17, 2017
Loading