Skip to content
Snippets Groups Projects
  1. Apr 04, 2021
    • Zheyu Ma's avatar
      firewire: nosy: Fix a use-after-free bug in nosy_ioctl() · 829933ef
      Zheyu Ma authored
      For each device, the nosy driver allocates a pcilynx structure.
      A use-after-free might happen in the following scenario:
      
       1. Open nosy device for the first time and call ioctl with command
          NOSY_IOC_START, then a new client A will be malloced and added to
          doubly linked list.
       2. Open nosy device for the second time and call ioctl with command
          NOSY_IOC_START, then a new client B will be malloced and added to
          doubly linked list.
       3. Call ioctl with command NOSY_IOC_START for client A, then client A
          will be readded to the doubly linked list. Now the doubly linked
          list is messed up.
       4. Close the first nosy device and nosy_release will be called. In
          nosy_release, client A will be unlinked and freed.
       5. Close the second nosy device, and client A will be referenced,
          resulting in UAF.
      
      The root cause of this bug is that the element in the doubly linked list
      is reentered into the list.
      
      Fix this bug by adding a check before inserting a client.  If a client
      is already in the linked list, don't insert it.
      
      The following KASAN report reveals it:
      
         BUG: KASAN: use-after-free in nosy_release+0x1ea/0x210
         Write of size 8 at addr ffff888102ad7360 by task poc
         CPU: 3 PID: 337 Comm: poc Not tainted 5.12.0-rc5+ #6
         Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
         Call Trace:
           nosy_release+0x1ea/0x210
           __fput+0x1e2/0x840
           task_work_run+0xe8/0x180
           exit_to_user_mode_prepare+0x114/0x120
           syscall_exit_to_user_mode+0x1d/0x40
           entry_SYSCALL_64_after_hwframe+0x44/0xae
      
         Allocated by task 337:
           nosy_open+0x154/0x4d0
           misc_open+0x2ec/0x410
           chrdev_open+0x20d/0x5a0
           do_dentry_open+0x40f/0xe80
           path_openat+0x1cf9/0x37b0
           do_filp_open+0x16d/0x390
           do_sys_openat2+0x11d/0x360
           __x64_sys_open+0xfd/0x1a0
           do_syscall_64+0x33/0x40
           entry_SYSCALL_64_after_hwframe+0x44/0xae
      
         Freed by task 337:
           kfree+0x8f/0x210
           nosy_release+0x158/0x210
           __fput+0x1e2/0x840
           task_work_run+0xe8/0x180
           exit_to_user_mode_prepare+0x114/0x120
           syscall_exit_to_user_mode+0x1d/0x40
           entry_SYSCALL_64_after_hwframe+0x44/0xae
      
         The buggy address belongs to the object at ffff888102ad7300 which belongs to the cache kmalloc-128 of size 128
         The buggy address is located 96 bytes inside of 128-byte region [ffff888102ad7300, ffff888102ad7380)
      
      [ Modified to use 'list_empty()' inside proper lock  - Linus ]
      
      Link: https://lore.kernel.org/lkml/1617433116-5930-1-git-send-email-zheyuma97@gmail.com/
      
      
      Reported-and-tested-by: default avatar马哲宇 (Zheyu Ma) <zheyuma97@gmail.com>
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Cc: Greg Kroah-Hartman <greg@kroah.com>
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      829933ef
  2. Apr 03, 2021
  3. Apr 01, 2021
  4. Mar 30, 2021
    • Hans de Goede's avatar
      ACPI: scan: Fix _STA getting called on devices with unmet dependencies · 3e759425
      Hans de Goede authored
      
      Commit 71da201f ("ACPI: scan: Defer enumeration of devices with
      _DEP lists") dropped the following 2 lines from acpi_init_device_object():
      
      	/* Assume there are unmet deps until acpi_device_dep_initialize() runs */
      	device->dep_unmet = 1;
      
      Leaving the initial value of dep_unmet at the 0 from the kzalloc(). This
      causes the acpi_bus_get_status() call in acpi_add_single_object() to
      actually call _STA, even though there maybe unmet deps, leading to errors
      like these:
      
      [    0.123579] ACPI Error: No handler for Region [ECRM] (00000000ba9edc4c)
                     [GenericSerialBus] (20170831/evregion-166)
      [    0.123601] ACPI Error: Region GenericSerialBus (ID=9) has no handler
                     (20170831/exfldio-299)
      [    0.123618] ACPI Error: Method parse/execution failed
                     \_SB.I2C1.BAT1._STA, AE_NOT_EXIST (20170831/psparse-550)
      
      Fix this by re-adding the dep_unmet = 1 initialization to
      acpi_init_device_object() and modifying acpi_bus_check_add() to make sure
      that dep_unmet always gets setup there, overriding the initial 1 value.
      
      This re-fixes the issue initially fixed by
      commit 63347db0 ("ACPI / scan: Use acpi_bus_get_status() to initialize
      ACPI_TYPE_DEVICE devs"), which introduced the removed
      "device->dep_unmet = 1;" statement.
      
      This issue was noticed; and the fix tested on a Dell Venue 10 Pro 5055.
      
      Fixes: 71da201f ("ACPI: scan: Defer enumeration of devices with _DEP lists")
      Suggested-by: default avatarRafael J. Wysocki <rafael@kernel.org>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Cc: 5.11+ <stable@vger.kernel.org> # 5.11+
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      3e759425
    • Thierry Reding's avatar
      drm/tegra: sor: Grab runtime PM reference across reset · ac097aec
      Thierry Reding authored
      
      The SOR resets are exclusively shared with the SOR power domain. This
      means that exclusive access can only be granted temporarily and in order
      for that to work, a rigorous sequence must be observed. To ensure that a
      single consumer gets exclusive access to a reset, each consumer must
      implement a rigorous protocol using the reset_control_acquire() and
      reset_control_release() functions.
      
      However, these functions alone don't provide any guarantees at the
      system level. Drivers need to ensure that the only a single consumer has
      access to the reset at the same time. In order for the SOR to be able to
      exclusively access its reset, it must therefore ensure that the SOR
      power domain is not powered off by holding on to a runtime PM reference
      to that power domain across the reset assert/deassert operation.
      
      This used to work fine by accident, but was revealed when recently more
      devices started to rely on the SOR power domain.
      
      Fixes: 11c632e1 ("drm/tegra: sor: Implement acquire/release for reset")
      Reported-by: default avatarJonathan Hunter <jonathanh@nvidia.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      ac097aec
    • Thierry Reding's avatar
      drm/tegra: dc: Restore coupling of display controllers · a31500fe
      Thierry Reding authored
      
      Coupling of display controllers used to rely on runtime PM to take the
      companion controller out of reset. Commit fd67e9c6 ("drm/tegra: Do
      not implement runtime PM") accidentally broke this when runtime PM was
      removed.
      
      Restore this functionality by reusing the hierarchical host1x client
      suspend/resume infrastructure that's similar to runtime PM and which
      perfectly fits this use-case.
      
      Fixes: fd67e9c6 ("drm/tegra: Do not implement runtime PM")
      Reported-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Reported-by: default avatarPaul Fertser <fercerpav@gmail.com>
      Tested-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      a31500fe
    • Mikko Perttunen's avatar
      gpu: host1x: Use different lock classes for each client · a24f9817
      Mikko Perttunen authored
      
      To avoid false lockdep warnings, give each client lock a different
      lock class, passed from the initialization site by macro.
      
      Signed-off-by: default avatarMikko Perttunen <mperttunen@nvidia.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      a24f9817
    • Dmitry Osipenko's avatar
      drm/tegra: dc: Don't set PLL clock to 0Hz · f8fb97c9
      Dmitry Osipenko authored
      
      RGB output doesn't allow to change parent clock rate of the display and
      PCLK rate is set to 0Hz in this case. The tegra_dc_commit_state() shall
      not set the display clock to 0Hz since this change propagates to the
      parent clock. The DISP clock is defined as a NODIV clock by the tegra-clk
      driver and all NODIV clocks use the CLK_SET_RATE_PARENT flag.
      
      This bug stayed unnoticed because by default PLLP is used as the parent
      clock for the display controller and PLLP silently skips the erroneous 0Hz
      rate changes because it always has active child clocks that don't permit
      rate changes. The PLLP isn't acceptable for some devices that we want to
      upstream (like Samsung Galaxy Tab and ASUS TF700T) due to a display panel
      clock rate requirements that can't be fulfilled by using PLLP and then the
      bug pops up in this case since parent clock is set to 0Hz, killing the
      display output.
      
      Don't touch DC clock if pclk=0 in order to fix the problem.
      
      Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      f8fb97c9
    • Gulam Mohamed's avatar
      scsi: iscsi: Fix race condition between login and sync thread · 9e67600e
      Gulam Mohamed authored
      A kernel panic was observed due to a timing issue between the sync thread
      and the initiator processing a login response from the target. The session
      reopen can be invoked both from the session sync thread when iscsid
      restarts and from iscsid through the error handler. Before the initiator
      receives the response to a login, another reopen request can be sent from
      the error handler/sync session. When the initial login response is
      subsequently processed, the connection has been closed and the socket has
      been released.
      
      To fix this a new connection state, ISCSI_CONN_BOUND, is added:
      
       - Set the connection state value to ISCSI_CONN_DOWN upon
         iscsi_if_ep_disconnect() and iscsi_if_stop_conn()
      
       - Set the connection state to the newly created value ISCSI_CONN_BOUND
         after bind connection (transport->bind_conn())
      
       - In iscsi_set_param(), return -ENOTCONN if the connection state is not
         either ISCSI_CONN_BOUND or ISCSI_CONN_UP
      
      Link: https://lore.kernel.org/r/20210325093248.284678-1-gulam.mohamed@oracle.com
      
      
      Reviewed-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarGulam Mohamed <gulam.mohamed@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      
      index 91074fd97f64..f4bf62b007a0 100644
      9e67600e
  5. Mar 29, 2021
  6. Mar 26, 2021
  7. Mar 25, 2021
Loading