1. 19 Oct, 2021 6 commits
    • David Lechner's avatar
      counter: drop chrdev_lock · f5245a5f
      David Lechner authored
      This removes the chrdev_lock from the counter subsystem. This was
      intended to prevent opening the chrdev more than once. However, this
      doesn't work in practice since userspace can duplicate file descriptors
      and pass file descriptors to other processes. Since this protection
      can't be relied on, it is best to just remove it.
      Suggested-by: default avatarGreg KH <gregkh@linuxfoundation.org>
      Acked-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
      Signed-off-by: default avatarDavid Lechner <david@lechnology.com>
      Link: https://lore.kernel.org/r/20211017185521.3468640-1-david@lechnology.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5245a5f
    • David Lechner's avatar
      counter/counter-sysfs: use sysfs_emit everywhere · c3ed761c
      David Lechner authored
      In the counter subsystem, we are already using sysfs_emit(), but there
      were a few places where we were still using sprintf() in *_show()
      functions. For consistency and added protections, use sysfs_emit()
      everywhere.
      Suggested-by: default avatarGreg KH <gregkh@linuxfoundation.org>
      Acked-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
      Signed-off-by: default avatarDavid Lechner <david@lechnology.com>
      Link: https://lore.kernel.org/r/20211017190106.3472645-1-david@lechnology.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c3ed761c
    • Ziyang Xuan's avatar
      char: xillybus: fix msg_ep UAF in xillyusb_probe() · 15c9a359
      Ziyang Xuan authored
      When endpoint_alloc() return failed in xillyusb_setup_base_eps(),
      'xdev->msg_ep' will be freed but not set to NULL. That lets program
      enter fail handling to cleanup_dev() in xillyusb_probe(). Check for
      'xdev->msg_ep' is invalid in cleanup_dev() because 'xdev->msg_ep' did
      not set to NULL when was freed. So the UAF problem for 'xdev->msg_ep'
      is triggered.
      
      ==================================================================
      BUG: KASAN: use-after-free in fifo_mem_release+0x1f4/0x210
      CPU: 0 PID: 166 Comm: kworker/0:2 Not tainted 5.15.0-rc5+ #19
      Call Trace:
       dump_stack_lvl+0xe2/0x152
       print_address_description.constprop.0+0x21/0x140
       ? fifo_mem_release+0x1f4/0x210
       kasan_report.cold+0x7f/0x11b
       ? xillyusb_probe+0x530/0x700
       ? fifo_mem_release+0x1f4/0x210
       fifo_mem_release+0x1f4/0x210
       ? __sanitizer_cov_trace_pc+0x1d/0x50
       endpoint_dealloc+0x35/0x2b0
       cleanup_dev+0x90/0x120
       xillyusb_probe+0x59a/0x700
      ...
      
      Freed by task 166:
       kasan_save_stack+0x1b/0x40
       kasan_set_track+0x1c/0x30
       kasan_set_free_info+0x20/0x30
       __kasan_slab_free+0x109/0x140
       kfree+0x117/0x4c0
       xillyusb_probe+0x606/0x700
      
      Set 'xdev->msg_ep' to NULL after being freed in xillyusb_setup_base_eps()
      to fix the UAF problem.
      
      Fixes: a53d1202 ("char: xillybus: Add driver for XillyUSB (Xillybus variant for USB)")
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarEli Billauer <eli.billauer@gmail.com>
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Link: https://lore.kernel.org/r/20211016052047.1611983-1-william.xuanziyang@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15c9a359
    • Todd Kjos's avatar
      binder: don't detect sender/target during buffer cleanup · 32e9f56a
      Todd Kjos authored
      When freeing txn buffers, binder_transaction_buffer_release()
      attempts to detect whether the current context is the target by
      comparing current->group_leader to proc->tsk. This is an unreliable
      test. Instead explicitly pass an 'is_failure' boolean.
      
      Detecting the sender was being used as a way to tell if the
      transaction failed to be sent.  When cleaning up after
      failing to send a transaction, there is no need to close
      the fds associated with a BINDER_TYPE_FDA object. Now
      'is_failure' can be used to accurately detect this case.
      
      Fixes: 44d8047f ("binder: use standard functions to allocate fds")
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Link: https://lore.kernel.org/r/20211015233811.3532235-1-tkjos@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      32e9f56a
    • Greg Kroah-Hartman's avatar
      Merge tag 'misc-habanalabs-next-2021-10-18' of... · be24dd48
      Greg Kroah-Hartman authored
      Merge tag 'misc-habanalabs-next-2021-10-18' of https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux into char-misc-next
      
      Oded writes:
      
      This tag contains habanalabs driver changes for v5.16:
      
      - Add a new uAPI (under the memory ioctl) to request from the driver
        to export a DMA-BUF object that represents a memory region on
        the device's DRAM. This is needed to enable peer-to-peer over PCIe
        between habana device and an RDMA adapter (e.g. mlnx5 or efa
        rdma adapter).
      
      - Add debugfs node to dynamically configure CS timeout. Up until now,
        it was only configurable through kernel module parameter.
      
      - Fetch more comprehensive power information from the firmware.
      
      - Always take timestamp when waiting for user interrupt, as the user
        needs that information to optimize the graph runtime compilation.
      
      - Modify user interrupt to look on 64-bit user value as fence, instead
        of 32-bit.
      
      - Bypass reset in case of repeated h/w error event after device reset.
        This is to prevent endless loop of resets to the device.
      
      - Fix several bugs in multi CS completion code.
      
      - Fix race condition in fd close/open.
      
      - Update to latest firmware headers
      
      - Add select CRC32 in kconfig
      
      - Small fixes, cosmetics
      
      * tag 'misc-habanalabs-next-2021-10-18' of https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux: (25 commits)
        habanalabs: refactor fence handling in hl_cs_poll_fences
        habanalabs: context cleanup cosmetics
        habanalabs: simplify wait for interrupt with timestamp flow
        habanalabs: initialize hpriv fields before adding new node
        habanalabs: Unify frequency set/get functionality
        habanalabs: select CRC32
        habanalabs: add support for dma-buf exporter
        habanalabs: define uAPI to export FD for DMA-BUF
        habanalabs: fix NULL pointer dereference
        habanalabs: fix race condition in multi CS completion
        habanalabs: use only u32
        habanalabs: update firmware files
        habanalabs: bypass reset for continuous h/w error event
        habanalabs: take timestamp on wait for interrupt
        habanalabs: prevent race between fd close/open
        habanalabs: refactor reset log message
        habanalabs: define soft-reset as inference op
        habanalabs: fix debugfs device memory MMU VA translation
        habanalabs: add support for a long interrupt target value
        habanalabs: remove redundant cs validity checks
        ...
      be24dd48
    • Greg Kroah-Hartman's avatar
      Merge tag 'counter-for-5.16a-take2' of... · 2b74240b
      Greg Kroah-Hartman authored
      Merge tag 'counter-for-5.16a-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next
      
      Jonathan writes:
      
      First set of counter subsystem new feature support for the 5.16 cycle
      
      Most interesting element this time is the new chrdev based interface
      for the counter subsystem.  Affects all drivers. Some minor precursor
      patches.
      
      Major parts:
      * Bring all the sysfs attribute setup into the counter core rather than
        leaving it to individual drivers.  Docs updates accompany these changes.
      * Move various definitions to a uapi header as now needed from userspace.
      * Add the chardev interface + extensive documentation and example tool
      * Add new ABI needed to identify indexes needed for chrdev interface
      * Implement new interface for the 104-quad-8
      * Follow up deals with wrong path for documentation build
      * Various trivial cleanups and missing feature additions related to this
        series
      
      * tag 'counter-for-5.16a-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
        docs: counter: Include counter-chrdev kernel-doc to generic-counter.rst
        counter: fix docum. build problems after filename change
        counter: microchip-tcb-capture: Tidy up a false kernel-doc /** marking.
        counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8
        counter: 104-quad-8: Replace mutex with spinlock
        counter: Implement events_queue_size sysfs attribute
        counter: Implement *_component_id sysfs attributes
        counter: Implement signalZ_action_component_id sysfs attribute
        tools/counter: Create Counter tools
        docs: counter: Document character device interface
        counter: Add character device interface
        counter: Move counter enums to uapi header
        docs: counter: Update to reflect sysfs internalization
        counter: Update counter.h comments to reflect sysfs internalization
        counter: Internalize sysfs interface code
        counter: stm32-timer-cnt: Provide defines for slave mode selection
        counter: stm32-lptimer-cnt: Provide defines for clock polarities
      2b74240b
  2. 18 Oct, 2021 34 commits