1. 23 2月, 2017 1 次提交
  2. 10 2月, 2017 8 次提交
    • M
      binder: Add support for file-descriptor arrays · def95c73
      Martijn Coenen 提交于
      This patch introduces a new binder_fd_array object,
      that allows us to support one or more file descriptors
      embedded in a buffer that is scatter-gathered.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      def95c73
    • M
      binder: Add support for scatter-gather · 7980240b
      Martijn Coenen 提交于
      Previously all data passed over binder needed
      to be serialized, with the exception of Binder
      objects and file descriptors.
      
      This patchs adds support for scatter-gathering raw
      memory buffers into a binder transaction, avoiding
      the need to first serialize them into a Parcel.
      
      To remain backwards compatibile with existing
      binder clients, it introduces two new command
      ioctls for this purpose - BC_TRANSACTION_SG and
      BC_REPLY_SG. These commands may only be used with
      the new binder_transaction_data_sg structure,
      which adds a field for the total size of the
      buffers we are scatter-gathering.
      
      Because memory buffers may contain pointers to
      other buffers, we allow callers to specify
      a parent buffer and an offset into it, to indicate
      this is a location pointing to the buffer that
      we are fixing up. The kernel will then take care
      of fixing up the pointer to that buffer as well.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      [jstultz: Fold in small fix from Amit Pundir <amit.pundir@linaro.org>]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7980240b
    • M
      binder: Add extra size to allocator · 4bfac80a
      Martijn Coenen 提交于
      The binder_buffer allocator currently only allocates
      space for the data and offsets buffers of a Parcel.
      This change allows for requesting an additional chunk
      of data in the buffer, which can for example be used
      to hold additional meta-data about the transaction
      (eg a security context).
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4bfac80a
    • M
      binder: Refactor binder_transact() · a056af42
      Martijn Coenen 提交于
      Moved handling of fixup for binder objects,
      handles and file descriptors into separate
      functions.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a056af42
    • M
      binder: Support multiple /dev instances · ac4812c5
      Martijn Coenen 提交于
      Add a new module parameter 'devices', that can be
      used to specify the names of the binder device
      nodes we want to populate in /dev.
      
      Each device node has its own context manager, and
      is therefore logically separated from all the other
      device nodes.
      
      The config option CONFIG_ANDROID_BINDER_DEVICES can
      be used to set the default value of the parameter.
      
      This approach was favored over using IPC namespaces,
      mostly because we require a single process to be a
      part of multiple binder contexts, which seemed harder
      to achieve with namespaces.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      [jstultz: minor checkpatch warning fix]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac4812c5
    • M
      binder: Deal with contexts in debugfs · 14db3181
      Martijn Coenen 提交于
      Properly print the context in debugfs entries.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14db3181
    • M
      binder: Support multiple context managers · 342e5c90
      Martijn Coenen 提交于
      Move the context manager state into a separate
      struct context, and allow for each process to have
      its own context associated with it.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      [jstultz: Minor checkpatch fix]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      342e5c90
    • M
      binder: Split flat_binder_object · feba3900
      Martijn Coenen 提交于
      flat_binder_object is used for both handling
      binder objects and file descriptors, even though
      the two are mostly independent. Since we'll
      have more fixup objects in binder in the future,
      instead of extending flat_binder_object again,
      split out file descriptors to their own object
      while retaining backwards compatibility to
      existing user-space clients. All binder objects
      just share a header.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Amit Pundir <amit.pundir@linaro.org>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Dmitry Shmidt <dimitrysh@google.com>
      Cc: Rom Lemarchand <romlem@google.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NMartijn Coenen <maco@google.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      feba3900
  3. 25 10月, 2016 2 次提交
  4. 18 8月, 2016 1 次提交
  5. 15 8月, 2016 2 次提交
    • B
      android: binder: Remove deprecated create_singlethread_workqueue · 1beba52d
      Bhaktipriya Shridhar 提交于
      The workqueue is being used to run deferred work for the android binder.
      
      The "binder_deferred_workqueue" queues only a single work item and hence
      does not require ordering. Also, this workqueue is not being used on a
      memory recliam path. Hence, the singlethreaded workqueue has been
      replaced with the use of system_wq.
      
      System workqueues have been able to handle high level of concurrency
      for a long time now and hence it's not required to have a singlethreaded
      workqueue just to gain concurrency. Unlike a dedicated per-cpu workqueue
      created with create_singlethread_workqueue(), system_wq allows multiple
      work items to overlap executions even on the same CPU; however, a
      per-cpu workqueue doesn't have any CPU locality or global ordering
      guarantee unless the target CPU is explicitly specified and thus the
      increase of local concurrency shouldn't make any difference.
      Signed-off-by: NBhaktipriya Shridhar <bhaktipriya96@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1beba52d
    • J
      android: binder: fix dangling pointer comparison · 7b142d8f
      Jann Horn 提交于
      If /dev/binder is opened and the opener process then e.g. calls execve,
      proc->vma_vm_mm will still point to the location of the now-freed
      mm_struct. If the process then calls ioctl(binder_fd, ...), the dangling
      proc->vma_vm_mm pointer will be compared to current->mm.
      
      Let the binder take a reference to the mm_struct to avoid this.
      
      v2: use the right refcounter
      
      Fixes: a906d693 ("android: binder: Sanity check at binder ioctl")
      Signed-off-by: NJann Horn <jannh@google.com>
      Reviewed-by: NChen Feng <puck.chen@hisilicon.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b142d8f
  6. 21 2月, 2016 1 次提交
  7. 12 2月, 2016 2 次提交
  8. 08 2月, 2016 1 次提交
  9. 11 9月, 2015 1 次提交
  10. 02 3月, 2015 1 次提交
    • A
      android: binder: fix binder mmap failures · f4c72c70
      Andrey Ryabinin 提交于
      binder_update_page_range() initializes only addr and size
      fields in 'struct vm_struct tmp_area;' and passes it to
      map_vm_area().
      
      Before 71394fe5 ("mm: vmalloc: add flag preventing guard hole allocation")
      this was because map_vm_area() didn't use any other fields
      in vm_struct except addr and size.
      
      Now get_vm_area_size() (used in map_vm_area()) reads vm_struct's
      flags to determine whether vm area has guard hole or not.
      
      binder_update_page_range() don't initialize flags field, so
      this causes following binder mmap failures:
      -----------[ cut here ]------------
      WARNING: CPU: 0 PID: 1971 at mm/vmalloc.c:130
      vmap_page_range_noflush+0x119/0x144()
      CPU: 0 PID: 1971 Comm: healthd Not tainted 4.0.0-rc1-00399-g7da3fdc-dirty #157
      Hardware name: ARM-Versatile Express
      [<c001246d>] (unwind_backtrace) from [<c000f7f9>] (show_stack+0x11/0x14)
      [<c000f7f9>] (show_stack) from [<c049a221>] (dump_stack+0x59/0x7c)
      [<c049a221>] (dump_stack) from [<c001cf21>] (warn_slowpath_common+0x55/0x84)
      [<c001cf21>] (warn_slowpath_common) from [<c001cfe3>]
      (warn_slowpath_null+0x17/0x1c)
      [<c001cfe3>] (warn_slowpath_null) from [<c00c66c5>]
      (vmap_page_range_noflush+0x119/0x144)
      [<c00c66c5>] (vmap_page_range_noflush) from [<c00c716b>] (map_vm_area+0x27/0x48)
      [<c00c716b>] (map_vm_area) from [<c038ddaf>]
      (binder_update_page_range+0x12f/0x27c)
      [<c038ddaf>] (binder_update_page_range) from [<c038e857>]
      (binder_mmap+0xbf/0x1ac)
      [<c038e857>] (binder_mmap) from [<c00c2dc7>] (mmap_region+0x2eb/0x4d4)
      [<c00c2dc7>] (mmap_region) from [<c00c3197>] (do_mmap_pgoff+0x1e7/0x250)
      [<c00c3197>] (do_mmap_pgoff) from [<c00b35b5>] (vm_mmap_pgoff+0x45/0x60)
      [<c00b35b5>] (vm_mmap_pgoff) from [<c00c1f39>] (SyS_mmap_pgoff+0x5d/0x80)
      [<c00c1f39>] (SyS_mmap_pgoff) from [<c000ce81>] (ret_fast_syscall+0x1/0x5c)
      ---[ end trace 48c2c4b9a1349e54 ]---
      binder: 1982: binder_alloc_buf failed to map page at f0e00000 in kernel
      binder: binder_mmap: 1982 b6bde000-b6cdc000 alloc small buf failed -12
      
      Use map_kernel_range_noflush() instead of map_vm_area() as this is better
      API for binder's purposes and it allows to get rid of 'vm_struct tmp_area' at all.
      
      Fixes: 71394fe5 ("mm: vmalloc: add flag preventing guard hole allocation")
      Signed-off-by: NAndrey Ryabinin <a.ryabinin@samsung.com>
      Reported-by: NAmit Pundir <amit.pundir@linaro.org>
      Tested-by: NAmit Pundir <amit.pundir@linaro.org>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Tested-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4c72c70
  11. 26 1月, 2015 1 次提交
    • S
      Add security hooks to binder and implement the hooks for SELinux. · 79af7307
      Stephen Smalley 提交于
      Add security hooks to the binder and implement the hooks for SELinux.
      The security hooks enable security modules such as SELinux to implement
      controls over binder IPC.  The security hooks include support for
      controlling what process can become the binder context manager
      (binder_set_context_mgr), controlling the ability of a process
      to invoke a binder transaction/IPC to another process (binder_transaction),
      controlling the ability of a process to transfer a binder reference to
      another process (binder_transfer_binder), and controlling the ability
      of a process to transfer an open file to another process (binder_transfer_file).
      
      These hooks have been included in the Android kernel trees since Android 4.3.
      
      (Updated to reflect upstream relocation and changes to the binder driver,
      changes to the LSM audit data structures, coding style cleanups, and
      to add inline documentation for the hooks).
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Acked-by: NNick Kralevich <nnk@google.com>
      Acked-by: NJeffrey Vander Stoep <jeffv@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      79af7307
  12. 20 10月, 2014 2 次提交
  13. 09 9月, 2014 2 次提交
  14. 07 8月, 2014 1 次提交
    • W
      mm/vmalloc.c: clean up map_vm_area third argument · f6f8ed47
      WANG Chao 提交于
      Currently map_vm_area() takes (struct page *** pages) as third argument,
      and after mapping, it moves (*pages) to point to (*pages +
      nr_mappped_pages).
      
      It looks like this kind of increment is useless to its caller these
      days.  The callers don't care about the increments and actually they're
      trying to avoid this by passing another copy to map_vm_area().
      
      The caller can always guarantee all the pages can be mapped into vm_area
      as specified in first argument and the caller only cares about whether
      map_vm_area() fails or not.
      
      This patch cleans up the pointer movement in map_vm_area() and updates
      its callers accordingly.
      Signed-off-by: NWANG Chao <chaowang@redhat.com>
      Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Nitin Gupta <ngupta@vflare.org>
      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>
      f6f8ed47
  15. 16 7月, 2014 1 次提交
  16. 09 7月, 2014 2 次提交
    • T
      staging: android: binder.c: binder_ioctl() cleanup · 78260ac6
      Tair Rzayev 提交于
      binder_ioctl() is quite huge and checkpatch dirty - mostly because of
      the amount of code for the BINDER_WRITE_READ and BINDER_SET_CONTEXT_MGR.
      Moved that code into the new binder_ioctl_write_read() and
      binder_ioctl_set_ctx_mgr()
      Signed-off-by: NTair Rzayev <tair.rzayev@gmail.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      78260ac6
    • V
      staging: binder: add vm_fault handler · ddac7d5f
      Vinayak Menon 提交于
      An issue was observed when a userspace task exits.
      The page which hits error here is the zero page.
      In binder mmap, the whole of vma is not mapped.
      On a task crash, when debuggerd reads the binder regions,
      the unmapped areas fall to do_anonymous_page in handle_pte_fault,
      due to the absence of a vm_fault handler. This results in
      zero page being mapped. Later in zap_pte_range, vm_normal_page
      returns zero page in the case of VM_MIXEDMAP and it results in the
      error.
      
      BUG: Bad page map in process mediaserver  pte:9dff379f pmd:9bfbd831
      page:c0ed8e60 count:1 mapcount:-1 mapping:  (null) index:0x0
      page flags: 0x404(referenced|reserved)
      addr:40c3f000 vm_flags:10220051 anon_vma:  (null) mapping:d9fe0764 index:fd
      vma->vm_ops->fault:   (null)
      vma->vm_file->f_op->mmap: binder_mmap+0x0/0x274
      CPU: 0 PID: 1463 Comm: mediaserver Tainted: G        W    3.10.17+ #1
      [<c001549c>] (unwind_backtrace+0x0/0x11c) from [<c001200c>] (show_stack+0x10/0x14)
      [<c001200c>] (show_stack+0x10/0x14) from [<c0103d78>] (print_bad_pte+0x158/0x190)
      [<c0103d78>] (print_bad_pte+0x158/0x190) from [<c01055f0>] (unmap_single_vma+0x2e4/0x598)
      [<c01055f0>] (unmap_single_vma+0x2e4/0x598) from [<c010618c>] (unmap_vmas+0x34/0x50)
      [<c010618c>] (unmap_vmas+0x34/0x50) from [<c010a9e4>] (exit_mmap+0xc8/0x1e8)
      [<c010a9e4>] (exit_mmap+0xc8/0x1e8) from [<c00520f0>] (mmput+0x54/0xd0)
      [<c00520f0>] (mmput+0x54/0xd0) from [<c005972c>] (do_exit+0x360/0x990)
      [<c005972c>] (do_exit+0x360/0x990) from [<c0059ef0>] (do_group_exit+0x84/0xc0)
      [<c0059ef0>] (do_group_exit+0x84/0xc0) from [<c0066de0>] (get_signal_to_deliver+0x4d4/0x548)
      [<c0066de0>] (get_signal_to_deliver+0x4d4/0x548) from [<c0011500>] (do_signal+0xa8/0x3b8)
      
      Add a vm_fault handler which returns VM_FAULT_SIGBUS, and prevents the
      wrong fallback to do_anonymous_page.
      Signed-off-by: NVinayak Menon <vinayakm.list@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ddac7d5f
  17. 27 6月, 2014 1 次提交
  18. 02 6月, 2014 1 次提交
  19. 23 5月, 2014 2 次提交
  20. 22 5月, 2014 1 次提交
  21. 04 5月, 2014 1 次提交
  22. 18 4月, 2014 1 次提交
  23. 17 4月, 2014 1 次提交
  24. 25 2月, 2014 1 次提交
    • A
      staging: binder: Support concurrent 32 bit and 64 bit processes. · da49889d
      Arve Hjønnevåg 提交于
      For 64bit systems we want to use the same binder interface for 32bit and
      64bit processes. Thus the size and the layout of the structures passed
      between the kernel and the userspace has to be the same for both 32 and
      64bit processes.
      
      This change replaces all the uses of void* and size_t with
      binder_uintptr_t and binder_size_t. These are then typedefed to specific
      sizes depending on the use of the interface, as follows:
             * __u32 - on legacy 32bit only userspace
             * __u64 - on mixed 32/64bit userspace where all processes use the same
      interface.
      
      This change also increments the BINDER_CURRENT_PROTOCOL_VERSION to 8 and
      hooks the compat_ioctl entry for the mixed 32/64bit Android userspace.
      
      This patch also provides a CONFIG_ANDROID_BINDER_IPC_32BIT option for
      compatability, which if set which enables the old protocol, setting
      BINDER_CURRENT_PROTOCOL_VERSION to 7, on 32 bit systems.
      
      Please note that all 64bit kernels will use the 64bit Binder ABI.
      
      Cc: Colin Cross <ccross@android.com>
      Cc: Arve Hjønnevåg <arve@android.com>
      Cc: Serban Constantinescu <serban.constantinescu@arm.com>
      Cc: Android Kernel Team <kernel-team@android.com>
      Signed-off-by: NArve Hjønnevåg <arve@android.com>
      [jstultz: Merged with upstream type changes. Various whitespace fixes
      and longer Kconfig description for checkpatch. Included improved commit
      message from Serban (with a few tweaks).]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      da49889d
  25. 22 2月, 2014 1 次提交
  26. 17 9月, 2013 1 次提交