Skip to content
  1. Sep 08, 2022
    • Heiner Kallweit's avatar
      usb: dwc2: fix wrong order of phy_power_on and phy_init · 48917032
      Heiner Kallweit authored
      commit f9b995b4 upstream.
      
      Since 1599069a ("phy: core: Warn when phy_power_on is called before
      phy_init") the driver complains. In my case (Amlogic SoC) the warning
      is: phy phy-fe03e000.phy.2: phy_power_on was called before phy_init
      So change the order of the two calls. The same change has to be done
      to the order of phy_exit() and phy_power_off().
      
      Fixes: 09a75e85
      
       ("usb: dwc2: refactor common low-level hw code to platform.c")
      Cc: stable@vger.kernel.org
      Acked-by: default avatarMinas Harutyunyan <hminas@synopsys.com>
      Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Link: https://lore.kernel.org/r/dfcc6b40-2274-4e86-e73c-5c5e6aa3e046@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      48917032
    • Badhri Jagan Sridharan's avatar
      usb: typec: tcpm: Return ENOTSUPP for power supply prop writes · ea72b22a
      Badhri Jagan Sridharan authored
      commit f2d38edc upstream.
      
      When the port does not support USB PD, prevent transition to PD
      only states when power supply property is written. In this case,
      TCPM transitions to SNK_NEGOTIATE_CAPABILITIES
      which should not be the case given that the port is not pd_capable.
      
      [   84.308251] state change SNK_READY -> SNK_NEGOTIATE_CAPABILITIES [rev3 NONE_AMS]
      [   84.308335] Setting usb_comm capable false
      [   84.323367] set_auto_vbus_discharge_threshold mode:3 pps_active:n vbus:5000 ret:0
      [   84.323376] state change SNK_NEGOTIATE_CAPABILITIES -> SNK_WAIT_CAPABILITIES [rev3 NONE_AMS]
      
      Fixes: e9e6e164
      
       ("usb: typec: tcpm: Support non-PD mode")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarBadhri Jagan Sridharan <badhri@google.com>
      Link: https://lore.kernel.org/r/20220817215410.1807477-1-badhri@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ea72b22a
    • Utkarsh Patel's avatar
      usb: typec: intel_pmc_mux: Add new ACPI ID for Meteor Lake IOM device · 4be500c6
      Utkarsh Patel authored
      commit 1b1b672c
      
       upstream.
      
      This adds the necessary ACPI ID for Intel Meteor Lake
      IOM devices.
      
      The callback function is_memory() is modified so that it
      also checks if the resource descriptor passed to it is a
      memory type "Address Space Resource Descriptor".
      
      On Intel Meteor Lake the ACPI memory resource is not
      described using the "32-bit Memory Range Descriptor" because
      the memory is outside of the 32-bit address space. The
      memory resource is described using the "Address Space
      Resource Descriptor" instead.
      
      Intel Meteor Lake is the first platform to describe the
      memory resource for this device with Address Space Resource
      Descriptor, but it most likely will not be the last.
      Therefore the change to the is_memory() callback function
      is made generic.
      
      Signed-off-by: default avatarUtkarsh Patel <utkarsh.h.patel@intel.com>
      Cc: stable@vger.kernel.org
      [ heikki: Rewrote the commit message. ]
      Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/20220816101629.69054-2-heikki.krogerus@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4be500c6
    • Pablo Sun's avatar
      usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles · b201f620
      Pablo Sun authored
      commit c1e5c2f0 upstream.
      
      Fix incorrect pin assignment values when connecting to a monitor with
      Type-C receptacle instead of a plug.
      
      According to specification, an UFP_D receptacle's pin assignment
      should came from the UFP_D pin assignments field (bit 23:16), while
      an UFP_D plug's assignments are described in the DFP_D pin assignments
      (bit 15:8) during Mode Discovery.
      
      For example the LG 27 UL850-W is a monitor with Type-C receptacle.
      The monitor responds to MODE DISCOVERY command with following
      DisplayPort Capability flag:
      
              dp->alt->vdo=0x140045
      
      The existing logic only take cares of UPF_D plug case,
      and would take the bit 15:8 for this 0x140045 case.
      
      This results in an non-existing pin assignment 0x0 in
      dp_altmode_configure.
      
      To fix this problem a new set of macros are introduced
      to take plug/receptacle differences into consideration.
      
      Fixes: 0e3bb7d6
      
       ("usb: typec: Add driver for DisplayPort alternate mode")
      Cc: stable@vger.kernel.org
      Co-developed-by: default avatarPablo Sun <pablo.sun@mediatek.com>
      Co-developed-by: default avatarMacpaul Lin <macpaul.lin@mediatek.com>
      Reviewed-by: default avatarGuillaume Ranquet <granquet@baylibre.com>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarPablo Sun <pablo.sun@mediatek.com>
      Signed-off-by: default avatarMacpaul Lin <macpaul.lin@mediatek.com>
      Link: https://lore.kernel.org/r/20220804034803.19486-1-macpaul.lin@mediatek.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b201f620
    • Slark Xiao's avatar
      USB: serial: option: add support for Cinterion MV32-WA/WB RmNet mode · 577f84a6
      Slark Xiao authored
      commit 8ffe20d0
      
       upstream.
      
      We added PIDs for MV32-WA/WB MBIM mode before, now we need to add
      support for RmNet mode.
      
      Test evidence as below:
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=03 Dev#=  3 Spd=480 MxCh= 0
      D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=1e2d ProdID=00f3 Rev=05.04
      S:  Manufacturer=Cinterion
      S:  Product=Cinterion PID 0x00F3 USB Mobile Broadband
      S:  SerialNumber=d7b4be8d
      C:  #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=500mA
      I:  If#=0x0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan
      I:  If#=0x1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      I:  If#=0x3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option
      
      T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=03 Dev#= 10 Spd=480 MxCh= 0
      D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=1e2d ProdID=00f4 Rev=05.04
      S:  Manufacturer=Cinterion
      S:  Product=Cinterion PID 0x00F4 USB Mobile Broadband
      S:  SerialNumber=d095087d
      C:  #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=500mA
      I:  If#=0x0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan
      I:  If#=0x1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      I:  If#=0x3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option
      
      Signed-off-by: default avatarSlark Xiao <slark_xiao@163.com>
      [ johan: sort entries ]
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      577f84a6
    • Yonglin Tan's avatar
      USB: serial: option: add Quectel EM060K modem · 64159539
      Yonglin Tan authored
      commit f766f3ab
      
       upstream.
      
      Add usb product id entry for the Quectel EM060K module.
      
      "MBIM mode": DIAG + NMEA + AT + MODEM + MBIM + QDSS
      
      T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  8 Spd=480  MxCh= 0
      D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=2c7c ProdID=030b Rev= 5.04
      S:  Manufacturer=Quectel
      S:  Product=EM060K-GL
      S:  SerialNumber=89fb57db
      C:* #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA
      A:  FirstIf#= 8 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00
      I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=40 Driver=option
      E:  Ad=83(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
      E:  Ad=87(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 8 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim
      E:  Ad=88(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
      I:  If#= 9 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
      I:* If#= 9 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
      E:  Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=0f(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#=12 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=70 Driver=(none)
      E:  Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      
      Signed-off-by: default avatarYonglin Tan <yonglin.tan@outlook.com>
      [ johan: mention QDSS port and sort entries ]
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64159539
    • Yan Xinyu's avatar
      USB: serial: option: add support for OPPO R11 diag port · 93c283a0
      Yan Xinyu authored
      commit 8d5fc280
      
       upstream.
      
      Add support for OPPO R11 USB diag serial port to option driver. This
      phone uses Qualcomm Snapdragon 660 SoC.
      
      usb-devices output:
      T:  Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 10 Spd=480 MxCh= 0
      D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=22d9 ProdID=276c Rev=04.04
      S:  Manufacturer=OPPO
      S:  Product=SDM660-MTP _SN:09C6BCA7
      S:  SerialNumber=beb2c403
      C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
      I:  If#=0x0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option
      I:  If#=0x1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs
      
      Signed-off-by: default avatarYan Xinyu <sdlyyxy@bupt.edu.cn>
      Link: https://lore.kernel.org/r/20220714102037.4113889-1-sdlyyxy@bupt.edu.cn
      Link: https://lore.kernel.org/r/Yt1WfSZk03Plpnan@hovoldconsulting.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93c283a0
    • Johan Hovold's avatar
      USB: serial: cp210x: add Decagon UCA device id · 2bb1ad8c
      Johan Hovold authored
      commit ceb40384
      
       upstream.
      
      Add the device id for Decagon Devices USB Cable Adapter.
      
      Link: https://lore.kernel.org/r/trinity-819f9db2-d3e1-40e9-a669-9c245817c046-1661523546680@msvc-mesg-web108
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2bb1ad8c
    • Mathias Nyman's avatar
      xhci: Add grace period after xHC start to prevent premature runtime suspend. · 3a6c5c5a
      Mathias Nyman authored
      commit 33e32158
      
       upstream.
      
      After xHC controller is started, either in probe or resume, it can take
      a while before any of the connected usb devices are visible to the roothub
      due to link training.
      
      It's possible xhci driver loads, sees no acivity and suspends the host
      before the USB device is visible.
      
      In one testcase with a hotplugged xHC controller the host finally detected
      the connected USB device and generated a wake 500ms after host initial
      start.
      
      If hosts didn't suspend the device duringe training it probablty wouldn't
      take up to 500ms to detect it, but looking at specs reveal USB3 link
      training has a couple long timeout values, such as 120ms
      RxDetectQuietTimeout, and 360ms PollingLFPSTimeout.
      
      So Add a 500ms grace period that keeps polling the roothub for 500ms after
      start, preventing runtime suspend until USB devices are detected.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20220825150840.132216-3-mathias.nyman@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a6c5c5a
    • Alan Stern's avatar
      media: mceusb: Use new usb_control_msg_*() routines · 75913c56
      Alan Stern authored
      commit 608e58a0
      
       upstream.
      
      Automatic kernel fuzzing led to a WARN about invalid pipe direction in
      the mceusb driver:
      
      ------------[ cut here ]------------
      usb 6-1: BOGUS control dir, pipe 80000380 doesn't match bRequestType 40
      WARNING: CPU: 0 PID: 2465 at drivers/usb/core/urb.c:410
      usb_submit_urb+0x1326/0x1820 drivers/usb/core/urb.c:410
      Modules linked in:
      CPU: 0 PID: 2465 Comm: kworker/0:2 Not tainted 5.19.0-rc4-00208-g69cb6c6556ad #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.13.0-1ubuntu1.1 04/01/2014
      Workqueue: usb_hub_wq hub_event
      RIP: 0010:usb_submit_urb+0x1326/0x1820 drivers/usb/core/urb.c:410
      Code: 7c 24 40 e8 ac 23 91 fd 48 8b 7c 24 40 e8 b2 70 1b ff 45 89 e8
      44 89 f1 4c 89 e2 48 89 c6 48 c7 c7 a0 30 a9 86 e8 48 07 11 02 <0f> 0b
      e9 1c f0 ff ff e8 7e 23 91 fd 0f b6 1d 63 22 83 05 31 ff 41
      RSP: 0018:ffffc900032becf0 EFLAGS: 00010282
      RAX: 0000000000000000 RBX: ffff8881100f3058 RCX: 0000000000000000
      RDX: ffffc90004961000 RSI: ffff888114c6d580 RDI: fffff52000657d90
      RBP: ffff888105ad90f0 R08: ffffffff812c3638 R09: 0000000000000000
      R10: 0000000000000005 R11: ffffed1023504ef1 R12: ffff888105ad9000
      R13: 0000000000000040 R14: 0000000080000380 R15: ffff88810ba96500
      FS: 0000000000000000(0000) GS:ffff88811a800000(0000) knlGS:0000000000000000
      CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffe810bda58 CR3: 000000010b720000 CR4: 0000000000350ef0
      Call Trace:
      <TASK>
      usb_start_wait_urb+0x101/0x4c0 drivers/usb/core/message.c:58
      usb_internal_control_msg drivers/usb/core/message.c:102 [inline]
      usb_control_msg+0x31c/0x4a0 drivers/usb/core/message.c:153
      mceusb_gen1_init drivers/media/rc/mceusb.c:1431 [inline]
      mceusb_dev_probe+0x258e/0x33f0 drivers/media/rc/mceusb.c:1807
      
      The reason for the warning is clear enough; the driver sends an
      unusual read request on endpoint 0 but does not set the USB_DIR_IN bit
      in the bRequestType field.
      
      More importantly, the whole situation can be avoided and the driver
      simplified by converting it over to the relatively new
      usb_control_msg_recv() and usb_control_msg_send() routines.  That's
      what this fix does.
      
      Link: https://lore.kernel.org/all/CAB7eexLLApHJwZfMQ=X-PtRhw0BgO+5KcSMS05FNUYejJXqtSA@mail.gmail.com/
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: stable@vger.kernel.org
      Reported-and-tested-by: default avatarRondreis <linhaoguo86@gmail.com>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/YwkfnBFCSEVC6XZu@rowland.harvard.edu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75913c56
    • Heikki Krogerus's avatar
      usb: dwc3: pci: Add support for Intel Raptor Lake · 2c948dd6
      Heikki Krogerus authored
      commit bad0d1d7
      
       upstream.
      
      This adds the necessary PCI device ID for the controller
      inside the Intel Raptor Lake CPU block. The controllers that
      are part of the PCH (chipset) have separate device IDs.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/20220815123334.87526-1-heikki.krogerus@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c948dd6
    • Mika Westerberg's avatar
      thunderbolt: Use the actual buffer in tb_async_error() · 23987d01
      Mika Westerberg authored
      commit eb100b8f upstream.
      
      The received notification packet is held in pkg->buffer and not in pkg
      itself. Fix this by using the correct buffer.
      
      Fixes: 81a54b5e
      
       ("thunderbolt: Let the connection manager handle all notifications")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23987d01
    • SeongJae Park's avatar
      xen-blkfront: Cache feature_persistent value before advertisement · e31db376
      SeongJae Park authored
      commit fe8f65b0 upstream.
      
      Xen blkfront advertises its support of the persistent grants feature
      when it first setting up and when resuming in 'talk_to_blkback()'.
      Then, blkback reads the advertised value when it connects with blkfront
      and decides if it will use the persistent grants feature or not, and
      advertises its decision to blkfront.  Blkfront reads the blkback's
      decision and it also makes the decision for the use of the feature.
      
      Commit 402c43ea ("xen-blkfront: Apply 'feature_persistent' parameter
      when connect"), however, made the blkfront's read of the parameter for
      disabling the advertisement, namely 'feature_persistent', to be done
      when it negotiate, not when advertise.  Therefore blkfront advertises
      without reading the parameter.  As the field for caching the parameter
      value is zero-initialized, it always advertises as the feature is
      disabled, so that the persistent grants feature becomes always disabled.
      
      This commit fixes the issue by making the blkfront does parmeter caching
      just before the advertisement.
      
      Fixes: 402c43ea
      
       ("xen-blkfront: Apply 'feature_persistent' parameter when connect")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Reported-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220831165824.94815-4-sj@kernel.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e31db376
    • SeongJae Park's avatar
      xen-blkfront: Advertise feature-persistent as user requested · 895a90ad
      SeongJae Park authored
      commit 9f5e0fe5 upstream.
      
      The advertisement of the persistent grants feature (writing
      'feature-persistent' to xenbus) should mean not the decision for using
      the feature but only the availability of the feature.  However, commit
      74a85247 ("xen-blkfront: add a parameter for disabling of persistent
      grants") made a field of blkfront, which was a place for saving only the
      negotiation result, to be used for yet another purpose: caching of the
      'feature_persistent' parameter value.  As a result, the advertisement,
      which should follow only the parameter value, becomes inconsistent.
      
      This commit fixes the misuse of the semantic by making blkfront saves
      the parameter value in a separate place and advertises the support based
      on only the saved value.
      
      Fixes: 74a85247
      
       ("xen-blkfront: add a parameter for disabling of persistent grants")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Suggested-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220831165824.94815-3-sj@kernel.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      895a90ad
    • SeongJae Park's avatar
      xen-blkback: Advertise feature-persistent as user requested · 3e8107d6
      SeongJae Park authored
      commit 06ba5d2e upstream.
      
      The advertisement of the persistent grants feature (writing
      'feature-persistent' to xenbus) should mean not the decision for using
      the feature but only the availability of the feature.  However, commit
      aac8a70d ("xen-blkback: add a parameter for disabling of persistent
      grants") made a field of blkback, which was a place for saving only the
      negotiation result, to be used for yet another purpose: caching of the
      'feature_persistent' parameter value.  As a result, the advertisement,
      which should follow only the parameter value, becomes inconsistent.
      
      This commit fixes the misuse of the semantic by making blkback saves the
      parameter value in a separate place and advertises the support based on
      only the saved value.
      
      Fixes: aac8a70d
      
       ("xen-blkback: add a parameter for disabling of persistent grants")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Suggested-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220831165824.94815-2-sj@kernel.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e8107d6
    • Steven Price's avatar
      mm: pagewalk: Fix race between unmap and page walker · c235c4fc
      Steven Price authored
      [ Upstream commit 8782fb61 ]
      
      The mmap lock protects the page walker from changes to the page tables
      during the walk.  However a read lock is insufficient to protect those
      areas which don't have a VMA as munmap() detaches the VMAs before
      downgrading to a read lock and actually tearing down PTEs/page tables.
      
      For users of walk_page_range() the solution is to simply call pte_hole()
      immediately without checking the actual page tables when a VMA is not
      present. We now never call __walk_page_range() without a valid vma.
      
      For walk_page_range_novma() the locking requirements are tightened to
      require the mmap write lock to be taken, and then walking the pgd
      directly with 'no_vma' set.
      
      This in turn means that all page walkers either have a valid vma, or
      it's that special 'novma' case for page table debugging.  As a result,
      all the odd '(!walk->vma && !walk->no_vma)' tests can be removed.
      
      Fixes: dd2283f2
      
       ("mm: mmap: zap pages with read mmap_sem in munmap")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarSteven Price <steven.price@arm.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c235c4fc
    • Dan Carpenter's avatar
      xen/grants: prevent integer overflow in gnttab_dma_alloc_pages() · 763d7724
      Dan Carpenter authored
      [ Upstream commit e9ea0b30 ]
      
      The change from kcalloc() to kvmalloc() means that arg->nr_pages
      might now be large enough that the "args->nr_pages << PAGE_SHIFT" can
      result in an integer overflow.
      
      Fixes: b3f7931f
      
       ("xen/gntdev: switch from kcalloc() to kvcalloc()")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/YxDROJqu/RPvR0bi@kili
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      763d7724
    • Jim Mattson's avatar
      KVM: x86: Mask off unsupported and unknown bits of IA32_ARCH_CAPABILITIES · 03b1870f
      Jim Mattson authored
      [ Upstream commit 0204750b ]
      
      KVM should not claim to virtualize unknown IA32_ARCH_CAPABILITIES
      bits. When kvm_get_arch_capabilities() was originally written, there
      were only a few bits defined in this MSR, and KVM could virtualize all
      of them. However, over the years, several bits have been defined that
      KVM cannot just blindly pass through to the guest without additional
      work (such as virtualizing an MSR promised by the
      IA32_ARCH_CAPABILITES feature bit).
      
      Define a mask of supported IA32_ARCH_CAPABILITIES bits, and mask off
      any other bits that are set in the hardware MSR.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Fixes: 5b76a3cf
      
       ("KVM: VMX: Tell the nested hypervisor to skip L1D flush on vmentry")
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarVipin Sharma <vipinsh@google.com>
      Reviewed-by: default avatarXiaoyao Li <xiaoyao.li@intel.com>
      Message-Id: <20220830174947.2182144-1-jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      03b1870f
    • Haibo Chen's avatar
      gpio: pca953x: Add mutex_lock for regcache sync in PM · 111a3586
      Haibo Chen authored
      [ Upstream commit 518e26f1 ]
      
      The regcache sync will set the cache_bypass = true, at that
      time, when there is regmap write operation, it will bypass
      the regmap cache, then the regcache sync will write back the
      value from cache to register, which is not as our expectation.
      
      Though regmap already use its internal lock to avoid such issue,
      but this driver force disable the regmap internal lock in its
      regmap config: disable_locking = true
      
      To avoid this issue, use the driver's own lock to do the protect
      in system PM.
      
      Fixes: b7657430
      
       ("gpio: pca953x: Restore registers after suspend/resume cycle")
      Signed-off-by: default avatarHaibo Chen <haibo.chen@nxp.com>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      111a3586
    • Armin Wolf's avatar
      hwmon: (gpio-fan) Fix array out of bounds access · 53196e03
      Armin Wolf authored
      [ Upstream commit f233d2be ]
      
      The driver does not check if the cooling state passed to
      gpio_fan_set_cur_state() exceeds the maximum cooling state as
      stored in fan_data->num_speeds. Since the cooling state is later
      used as an array index in set_fan_speed(), an array out of bounds
      access can occur.
      This can be exploited by setting the state of the thermal cooling device
      to arbitrary values, causing for example a kernel oops when unavailable
      memory is accessed this way.
      
      Example kernel oops:
      [  807.987276] Unable to handle kernel paging request at virtual address ffffff80d0588064
      [  807.987369] Mem abort info:
      [  807.987398]   ESR = 0x96000005
      [  807.987428]   EC = 0x25: DABT (current EL), IL = 32 bits
      [  807.987477]   SET = 0, FnV = 0
      [  807.987507]   EA = 0, S1PTW = 0
      [  807.987536]   FSC = 0x05: level 1 translation fault
      [  807.987570] Data abort info:
      [  807.987763]   ISV = 0, ISS = 0x00000005
      [  807.987801]   CM = 0, WnR = 0
      [  807.987832] swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000001165000
      [  807.987872] [ffffff80d0588064] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
      [  807.987961] Internal error: Oops: 96000005 [#1] PREEMPT SMP
      [  807.987992] Modules linked in: cmac algif_hash aes_arm64 algif_skcipher af_alg bnep hci_uart btbcm bluetooth ecdh_generic ecc 8021q garp stp llc snd_soc_hdmi_codec brcmfmac vc4 brcmutil cec drm_kms_helper snd_soc_core cfg80211 snd_compress bcm2835_codec(C) snd_pcm_dmaengine syscopyarea bcm2835_isp(C) bcm2835_v4l2(C) sysfillrect v4l2_mem2mem bcm2835_mmal_vchiq(C) raspberrypi_hwmon sysimgblt videobuf2_dma_contig videobuf2_vmalloc fb_sys_fops videobuf2_memops rfkill videobuf2_v4l2 videobuf2_common i2c_bcm2835 snd_bcm2835(C) videodev snd_pcm snd_timer snd mc vc_sm_cma(C) gpio_fan uio_pdrv_genirq uio drm fuse drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
      [  807.988508] CPU: 0 PID: 1321 Comm: bash Tainted: G         C        5.15.56-v8+ #1575
      [  807.988548] Hardware name: Raspberry Pi 3 Model B Rev 1.2 (DT)
      [  807.988574] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [  807.988608] pc : set_fan_speed.part.5+0x34/0x80 [gpio_fan]
      [  807.988654] lr : gpio_fan_set_cur_state+0x34/0x50 [gpio_fan]
      [  807.988691] sp : ffffffc008cf3bd0
      [  807.988710] x29: ffffffc008cf3bd0 x28: ffffff80019edac0 x27: 0000000000000000
      [  807.988762] x26: 0000000000000000 x25: 0000000000000000 x24: ffffff800747c920
      [  807.988787] x23: 000000000000000a x22: ffffff800369f000 x21: 000000001999997c
      [  807.988854] x20: ffffff800369f2e8 x19: ffffff8002ae8080 x18: 0000000000000000
      [  807.988877] x17: 0000000000000000 x16: 0000000000000000 x15: 000000559e271b70
      [  807.988938] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
      [  807.988960] x11: 0000000000000000 x10: ffffffc008cf3c20 x9 : ffffffcfb60c741c
      [  807.989018] x8 : 000000000000000a x7 : 00000000ffffffc9 x6 : 0000000000000009
      [  807.989040] x5 : 000000000000002a x4 : 0000000000000000 x3 : ffffff800369f2e8
      [  807.989062] x2 : 000000000000e780 x1 : 0000000000000001 x0 : ffffff80d0588060
      [  807.989084] Call trace:
      [  807.989091]  set_fan_speed.part.5+0x34/0x80 [gpio_fan]
      [  807.989113]  gpio_fan_set_cur_state+0x34/0x50 [gpio_fan]
      [  807.989199]  cur_state_store+0x84/0xd0
      [  807.989221]  dev_attr_store+0x20/0x38
      [  807.989262]  sysfs_kf_write+0x4c/0x60
      [  807.989282]  kernfs_fop_write_iter+0x130/0x1c0
      [  807.989298]  new_sync_write+0x10c/0x190
      [  807.989315]  vfs_write+0x254/0x378
      [  807.989362]  ksys_write+0x70/0xf8
      [  807.989379]  __arm64_sys_write+0x24/0x30
      [  807.989424]  invoke_syscall+0x4c/0x110
      [  807.989442]  el0_svc_common.constprop.3+0xfc/0x120
      [  807.989458]  do_el0_svc+0x2c/0x90
      [  807.989473]  el0_svc+0x24/0x60
      [  807.989544]  el0t_64_sync_handler+0x90/0xb8
      [  807.989558]  el0t_64_sync+0x1a0/0x1a4
      [  807.989579] Code: b9403801 f9402800 7100003f 8b35cc00 (b9400416)
      [  807.989627] ---[ end trace 8ded4c918658445b ]---
      
      Fix this by checking the cooling state and return an error if it
      exceeds the maximum cooling state.
      
      Tested on a Raspberry Pi 3.
      
      Fixes: b5cf88e4
      
       ("(gpio-fan): Add thermal control hooks")
      Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
      Link: https://lore.kernel.org/r/20220830011101.178843-1-W_Armin@gmx.de
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      53196e03
    • Stefan Wahren's avatar
      clk: bcm: rpi: Add missing newline · 7b8a284f
      Stefan Wahren authored
      [ Upstream commit 13b5cf8d ]
      
      Some log messages lacks the final newline. So add them.
      
      Fixes: 93d2725a
      
       ("clk: bcm: rpi: Discover the firmware clocks")
      Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Link: https://lore.kernel.org/r/20220713154953.3336-3-stefan.wahren@i2se.com
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarIvan T. Ivanov <iivanov@suse.de>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7b8a284f
    • Stefan Wahren's avatar
      clk: bcm: rpi: Prevent out-of-bounds access · ff0b144d
      Stefan Wahren authored
      [ Upstream commit bc163555 ]
      
      The while loop in raspberrypi_discover_clocks() relies on the assumption
      that the id of the last clock element is zero. Because this data comes
      from the Videocore firmware and it doesn't guarantuee such a behavior
      this could lead to out-of-bounds access. So fix this by providing
      a sentinel element.
      
      Fixes: 93d2725a
      
       ("clk: bcm: rpi: Discover the firmware clocks")
      Link: https://github.com/raspberrypi/firmware/issues/1688
      Suggested-by: default avatarPhil Elwell <phil@raspberrypi.com>
      Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Link: https://lore.kernel.org/r/20220713154953.3336-2-stefan.wahren@i2se.com
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarIvan T. Ivanov <iivanov@suse.de>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff0b144d
    • Christophe JAILLET's avatar
      clk: bcm: rpi: Use correct order for the parameters of devm_kcalloc() · e827a5f3
      Christophe JAILLET authored
      [ Upstream commit b7fa6242
      
       ]
      
      We should have 'n', then 'size', not the opposite.
      This is harmless because the 2 values are just multiplied, but having
      the correct order silence a (unpublished yet) smatch warning.
      
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Link: https://lore.kernel.org/r/49d726d11964ca0e3757bdb5659e3b3eaa1572b5.1653081643.git.christophe.jaillet@wanadoo.fr
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e827a5f3
    • Stefan Wahren's avatar
      clk: bcm: rpi: Fix error handling of raspberrypi_fw_get_rate · 237b4ef4
      Stefan Wahren authored
      [ Upstream commit 35f73cca
      
       ]
      
      The function raspberrypi_fw_get_rate (e.g. used for the recalc_rate
      hook) can fail to get the clock rate from the firmware. In this case
      we cannot return a signed error value, which would be casted to
      unsigned long. Fix this by returning 0 instead.
      
      Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Link: https://lore.kernel.org/r/20220625083643.4012-1-stefan.wahren@i2se.com
      Fixes: 4e85e535
      
       ("clk: bcm283x: add driver interfacing with Raspberry Pi's firmware")
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      237b4ef4
    • Peter Robinson's avatar
      Input: rk805-pwrkey - fix module autoloading · 5ba6155d
      Peter Robinson authored
      [ Upstream commit 99077ad6 ]
      
      Add the module alias so the rk805-pwrkey driver will
      autoload when built as a module.
      
      Fixes: 5a35b85c
      
       ("Input: add power key driver for Rockchip RK805 PMIC")
      Signed-off-by: default avatarPeter Robinson <pbrobinson@gmail.com>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Link: https://lore.kernel.org/r/20220612225437.3628788-1-pbrobinson@gmail.com
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5ba6155d
    • Chen-Yu Tsai's avatar
      clk: core: Fix runtime PM sequence in clk_core_unprepare() · 9766749a
      Chen-Yu Tsai authored
      [ Upstream commit 4b592061 ]
      
      In the original commit 9a34b453 ("clk: Add support for runtime PM"),
      the commit message mentioned that pm_runtime_put_sync() would be done
      at the end of clk_core_unprepare(). This mirrors the operations in
      clk_core_prepare() in the opposite order.
      
      However, the actual code that was added wasn't in the order the commit
      message described. Move clk_pm_runtime_put() to the end of
      clk_core_unprepare() so that it is in the correct order.
      
      Fixes: 9a34b453
      
       ("clk: Add support for runtime PM")
      Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Reviewed-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
      Link: https://lore.kernel.org/r/20220822081424.1310926-3-wenst@chromium.org
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9766749a
    • Stephen Boyd's avatar
      Revert "clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops" · c13b0be5
      Stephen Boyd authored
      [ Upstream commit abb5f3f4 ]
      
      This reverts commit 35b0fac8
      
      . Alexander
      reports that it causes boot failures on i.MX8M Plus based boards
      (specifically imx8mp-tqma8mpql-mba8mpxl.dts).
      
      Reported-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
      Cc: Chen-Yu Tsai <wenst@chromium.org>
      Fixes: 35b0fac8
      
       ("clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops")
      Link: https://lore.kernel.org/r/12115951.O9o76ZdvQC@steina-w
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Link: https://lore.kernel.org/r/20220831175326.2523912-1-sboyd@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c13b0be5
    • Chen-Yu Tsai's avatar
      clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops · 519cd9c4
      Chen-Yu Tsai authored
      [ Upstream commit 35b0fac8 ]
      
      In the previous commits that added CLK_OPS_PARENT_ENABLE, support for
      this flag was only added to rate change operations (rate setting and
      reparent) and disabling unused subtree. It was not added to the
      clock gate related operations. Any hardware driver that needs it for
      these operations will either see bogus results, or worse, hang.
      
      This has been seen on MT8192 and MT8195, where the imp_ii2_* clk
      drivers set this, but dumping debugfs clk_summary would cause it
      to hang.
      
      Fixes: fc8726a2 ("clk: core: support clocks which requires parents enable (part 2)")
      Fixes: a4b3518d
      
       ("clk: core: support clocks which requires parents enable (part 1)")
      Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Reviewed-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
      Tested-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
      Link: https://lore.kernel.org/r/20220822081424.1310926-2-wenst@chromium.org
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      519cd9c4
    • Colin Ian King's avatar
      drm/i915/reg: Fix spelling mistake "Unsupport" -> "Unsupported" · 0522550a
      Colin Ian King authored
      [ Upstream commit 233f5674 ]
      
      There is a spelling mistake in a gvt_vgpu_err error message. Fix it.
      
      Fixes: 695fbc08
      
       ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20220315202449.2952845-1-colin.i.king@gmail.com
      Reviewed-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0522550a
    • Jim Mattson's avatar
      KVM: VMX: Heed the 'msr' argument in msr_write_intercepted() · fec48eba
      Jim Mattson authored
      [ Upstream commit 020dac41 ]
      
      Regardless of the 'msr' argument passed to the VMX version of
      msr_write_intercepted(), the function always checks to see if a
      specific MSR (IA32_SPEC_CTRL) is intercepted for write.  This behavior
      seems unintentional and unexpected.
      
      Modify the function so that it checks to see if the provided 'msr'
      index is intercepted for write.
      
      Fixes: 67f4b996
      
       ("KVM: nVMX: Handle dynamic MSR intercept toggling")
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20220810213050.2655000-1-jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fec48eba
    • Enzo Matsumiya's avatar
      cifs: fix small mempool leak in SMB2_negotiate() · 9e3c9efa
      Enzo Matsumiya authored
      commit 27893dfc
      
       upstream.
      
      In some cases of failure (dialect mismatches) in SMB2_negotiate(), after
      the request is sent, the checks would return -EIO when they should be
      rather setting rc = -EIO and jumping to neg_exit to free the response
      buffer from mempool.
      
      Signed-off-by: default avatarEnzo Matsumiya <ematsumiya@suse.de>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e3c9efa
    • Carlos Llamas's avatar
      binder: fix alloc->vma_vm_mm null-ptr dereference · 81203ab7
      Carlos Llamas authored
      commit 1da52815 upstream.
      
      Syzbot reported a couple issues introduced by commit 44e602b4
      ("binder_alloc: add missing mmap_lock calls when using the VMA"), in
      which we attempt to acquire the mmap_lock when alloc->vma_vm_mm has not
      been initialized yet.
      
      This can happen if a binder_proc receives a transaction without having
      previously called mmap() to setup the binder_proc->alloc space in [1].
      Also, a similar issue occurs via binder_alloc_print_pages() when we try
      to dump the debugfs binder stats file in [2].
      
      Sample of syzbot's crash report:
        ==================================================================
        KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f]
        CPU: 0 PID: 3755 Comm: syz-executor229 Not tainted 6.0.0-rc1-next-20220819-syzkaller #0
        syz-executor229[3755] cmdline: ./syz-executor2294415195
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
        RIP: 0010:__lock_acquire+0xd83/0x56d0 kernel/locking/lockdep.c:4923
        [...]
        Call Trace:
         <TASK>
         lock_acquire kernel/locking/lockdep.c:5666 [inline]
         lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
         down_read+0x98/0x450 kernel/locking/rwsem.c:1499
         mmap_read_lock include/linux/mmap_lock.h:117 [inline]
         binder_alloc_new_buf_locked drivers/android/binder_alloc.c:405 [inline]
         binder_alloc_new_buf+0xa5/0x19e0 drivers/android/binder_alloc.c:593
         binder_transaction+0x242e/0x9a80 drivers/android/binder.c:3199
         binder_thread_write+0x664/0x3220 drivers/android/binder.c:3986
         binder_ioctl_write_read drivers/android/binder.c:5036 [inline]
         binder_ioctl+0x3470/0x6d00 drivers/android/binder.c:5323
         vfs_ioctl fs/ioctl.c:51 [inline]
         __do_sys_ioctl fs/ioctl.c:870 [inline]
         __se_sys_ioctl fs/ioctl.c:856 [inline]
         __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
         do_syscall_x64 arch/x86/entry/common.c:50 [inline]
         do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
         entry_SYSCALL_64_after_hwframe+0x63/0xcd
         [...]
        ==================================================================
      
      Fix these issues by setting up alloc->vma_vm_mm pointer during open()
      and caching directly from current->mm. This guarantees we have a valid
      reference to take the mmap_lock during scenarios described above.
      
      [1] https://syzkaller.appspot.com/bug?extid=f7dc54e5be28950ac459
      [2] https://syzkaller.appspot.com/bug?extid=a75ebe0452711c9e56d9
      
      Fixes: 44e602b4
      
       ("binder_alloc: add missing mmap_lock calls when using the VMA")
      Cc: <stable@vger.kernel.org> # v5.15+
      Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
      Reported-by: default avatar <syzbot+f7dc54e5be28950ac459@syzkaller.appspotmail.com>
      Reported-by: default avatar <syzbot+a75ebe0452711c9e56d9@syzkaller.appspotmail.com>
      Reviewed-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
      Acked-by: default avatarTodd Kjos <tkjos@google.com>
      Signed-off-by: default avatarCarlos Llamas <cmllamas@google.com>
      Link: https://lore.kernel.org/r/20220829201254.1814484-2-cmllamas@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81203ab7
    • Carlos Llamas's avatar
      binder: fix UAF of ref->proc caused by race condition · c2a4b5dc
      Carlos Llamas authored
      commit a0e44c64
      
       upstream.
      
      A transaction of type BINDER_TYPE_WEAK_HANDLE can fail to increment the
      reference for a node. In this case, the target proc normally releases
      the failed reference upon close as expected. However, if the target is
      dying in parallel the call will race with binder_deferred_release(), so
      the target could have released all of its references by now leaving the
      cleanup of the new failed reference unhandled.
      
      The transaction then ends and the target proc gets released making the
      ref->proc now a dangling pointer. Later on, ref->node is closed and we
      attempt to take spin_lock(&ref->proc->inner_lock), which leads to the
      use-after-free bug reported below. Let's fix this by cleaning up the
      failed reference on the spot instead of relying on the target to do so.
      
        ==================================================================
        BUG: KASAN: use-after-free in _raw_spin_lock+0xa8/0x150
        Write of size 4 at addr ffff5ca207094238 by task kworker/1:0/590
      
        CPU: 1 PID: 590 Comm: kworker/1:0 Not tainted 5.19.0-rc8 #10
        Hardware name: linux,dummy-virt (DT)
        Workqueue: events binder_deferred_func
        Call trace:
         dump_backtrace.part.0+0x1d0/0x1e0
         show_stack+0x18/0x70
         dump_stack_lvl+0x68/0x84
         print_report+0x2e4/0x61c
         kasan_report+0xa4/0x110
         kasan_check_range+0xfc/0x1a4
         __kasan_check_write+0x3c/0x50
         _raw_spin_lock+0xa8/0x150
         binder_deferred_func+0x5e0/0x9b0
         process_one_work+0x38c/0x5f0
         worker_thread+0x9c/0x694
         kthread+0x188/0x190
         ret_from_fork+0x10/0x20
      
      Acked-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Signed-off-by: default avatarCarlos Llamas <cmllamas@google.com>
      Cc: stable <stable@kernel.org> # 4.14+
      Link: https://lore.kernel.org/r/20220801182511.3371447-1-cmllamas@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2a4b5dc
    • Adrian Hunter's avatar
      mmc: core: Fix inconsistent sd3_bus_mode at UHS-I SD voltage switch failure · da3c6d07
      Adrian Hunter authored
      commit 63f15609
      
       upstream.
      
      If re-initialization results is a different signal voltage, because the
      voltage switch failed previously, but not this time (or vice versa), then
      sd3_bus_mode will be inconsistent with the card because the SD_SWITCH
      command is done only upon first initialization.
      
      Fix by always reading SD_SWITCH information during re-initialization, which
      also means it does not need to be re-read later for the 1.8V fixup
      workaround.
      
      Note, brief testing showed SD_SWITCH took about 1.8ms to 2ms which added
      about 1% to 1.5% to the re-initialization time, so it's not particularly
      significant.
      
      Reported-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Tested-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220815073321.63382-3-adrian.hunter@intel.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      da3c6d07
    • Adrian Hunter's avatar
      mmc: core: Fix UHS-I SD 1.8V workaround branch · 8bca2297
      Adrian Hunter authored
      commit 15c56208 upstream.
      
      When introduced, upon success, the 1.8V fixup workaround in
      mmc_sd_init_card() would branch to practically the end of the function, to
      a label named "done". Unfortunately, perhaps due to the label name, over
      time new code has been added that really should have come after "done" not
      before it. Let's fix the problem by moving the label to the correct place
      and rename it "cont".
      
      Fixes: 045d705d
      
       ("mmc: core: Enable the MMC host software queue for the SD card")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220815073321.63382-2-adrian.hunter@intel.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8bca2297
    • Niek Nooijens's avatar
      USB: serial: ftdi_sio: add Omron CS1W-CIF31 device id · fc9b5b3f
      Niek Nooijens authored
      commit 001047ea
      
       upstream.
      
      works perfectly with:
      modprobe ftdi_sio
      echo "0590 00b2" | tee
      /sys/module/ftdi_sio/drivers/usb-serial\:ftdi_sio/new_id > /dev/null
      
      but doing this every reboot is a pain in the ass.
      
      Signed-off-by: default avatarNiek Nooijens <niek.nooijens@omron.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc9b5b3f
    • Johan Hovold's avatar
      misc: fastrpc: fix memory corruption on open · cf20c353
      Johan Hovold authored
      commit d245f43a upstream.
      
      The probe session-duplication overflow check incremented the session
      count also when there were no more available sessions so that memory
      beyond the fixed-size slab-allocated session array could be corrupted in
      fastrpc_session_alloc() on open().
      
      Fixes: f6f9279f
      
       ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
      Cc: stable@vger.kernel.org      # 5.1
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220829080531.29681-3-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf20c353
    • Johan Hovold's avatar
      misc: fastrpc: fix memory corruption on probe · 0e33b0f3
      Johan Hovold authored
      commit 9baa1415 upstream.
      
      Add the missing sanity check on the probed-session count to avoid
      corrupting memory beyond the fixed-size slab-allocated session array
      when there are more than FASTRPC_MAX_SESSIONS sessions defined in the
      devicetree.
      
      Fixes: f6f9279f
      
       ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
      Cc: stable@vger.kernel.org      # 5.1
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220829080531.29681-2-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e33b0f3
    • Marcus Folkesson's avatar
      iio: adc: mcp3911: use correct formula for AD conversion · 95ac9601
      Marcus Folkesson authored
      commit 9e2238e3 upstream.
      
      The ADC conversion is actually not rail-to-rail but with a factor 1.5.
      Make use of this factor when calculating actual voltage.
      
      Fixes: 3a89b289
      
       ("iio: adc: add support for mcp3911")
      Signed-off-by: default avatarMarcus Folkesson <marcus.folkesson@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Link: https://lore.kernel.org/r/20220722130726.7627-4-marcus.folkesson@gmail.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95ac9601
    • Matti Vaittinen's avatar
      iio: ad7292: Prevent regulator double disable · 6e933a26
      Matti Vaittinen authored
      commit 22b42776 upstream.
      
      The ad7292 tries to add an devm_action for disabling a regulator at
      device detach using devm_add_action_or_reset(). The
      devm_add_action_or_reset() does call the release function should adding
      action fail. The driver inspects the value returned by
      devm_add_action_or_reset() and manually calls regulator_disable() if
      adding the action has failed. This leads to double disable and messes
      the enable count for regulator.
      
      Do not manually call disable if devm_add_action_or_reset() fails.
      
      Fixes: 506d2e31
      
       ("iio: adc: Add driver support for AD7292")
      Signed-off-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
      Tested-by: default avatarMarcelo Schmitt <marcelo.schmitt1@gmail.com>
      Link: https://lore.kernel.org/r/Yv9O+9sxU7gAv3vM@fedora
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e933a26