Skip to content
  1. Feb 02, 2022
    • Christophe Leroy's avatar
      powerpc/32: Fix boot failure with GCC latent entropy plugin · 7e945394
      Christophe Leroy authored
      commit bba49665 upstream.
      
      Boot fails with GCC latent entropy plugin enabled.
      
      This is due to early boot functions trying to access 'latent_entropy'
      global data while the kernel is not relocated at its final
      destination yet.
      
      As there is no way to tell GCC to use PTRRELOC() to access it,
      disable latent entropy plugin in early_32.o and feature-fixups.o and
      code-patching.o
      
      Fixes: 38addce8
      
       ("gcc-plugins: Add latent_entropy plugin")
      Cc: stable@vger.kernel.org # v4.9+
      Reported-by: default avatarErhard Furtner <erhard_f@mailbox.org>
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=215217
      Link: https://lore.kernel.org/r/2bac55483b8daf5b1caa163a45fa5f9cdbe18be4.1640178426.git.christophe.leroy@csgroup.eu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e945394
    • Marek Behún's avatar
      net: sfp: ignore disabled SFP node · ff19d70b
      Marek Behún authored
      commit 2148927e upstream.
      
      Commit ce0aa27f ("sfp: add sfp-bus to bridge between network devices
      and sfp cages") added code which finds SFP bus DT node even if the node
      is disabled with status = "disabled". Because of this, when phylink is
      created, it ends with non-null .sfp_bus member, even though the SFP
      module is not probed (because the node is disabled).
      
      We need to ignore disabled SFP bus node.
      
      Fixes: ce0aa27f
      
       ("sfp: add sfp-bus to bridge between network devices and sfp cages")
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Cc: stable@vger.kernel.org # 2203cbf2
      
       ("net: sfp: move fwnode parsing into sfp-bus layer")
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      [ backport to 5.4 ]
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ff19d70b
    • Sing-Han Chen's avatar
      ucsi_ccg: Check DEV_INT bit only when starting CCG4 · 5ede72d4
      Sing-Han Chen authored
      commit 82591149 upstream.
      
      CCGx clears Bit 0:Device Interrupt in the INTR_REG
      if CCGx is reset successfully. However, there might
      be a chance that other bits in INTR_REG are not
      cleared due to internal data queued in PPM. This case
      misleads the driver that CCGx reset failed.
      
      The commit checks bit 0 in INTR_REG and ignores other
      bits. The ucsi driver would reset PPM later.
      
      Fixes: 247c554a
      
       ("usb: typec: ucsi: add support for Cypress CCGx")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarSing-Han Chen <singhanc@nvidia.com>
      Signed-off-by: default avatarWayne Chang <waynec@nvidia.com>
      Link: https://lore.kernel.org/r/20220112094143.628610-1-waynec@nvidia.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5ede72d4
    • Badhri Jagan Sridharan's avatar
      usb: typec: tcpm: Do not disconnect while receiving VBUS off · 3922b6e1
      Badhri Jagan Sridharan authored
      commit 90b8aa9f upstream.
      
      With some chargers, vbus might momentarily raise above VSAFE5V and fall
      back to 0V before tcpm gets to read port->tcpc->get_vbus. This will
      will report a VBUS off event causing TCPM to transition to
      SNK_UNATTACHED where it should be waiting in either SNK_ATTACH_WAIT
      or SNK_DEBOUNCED state. This patch makes TCPM avoid vbus off events
      while in SNK_ATTACH_WAIT or SNK_DEBOUNCED state.
      
      Stub from the spec:
          "4.5.2.2.4.2 Exiting from AttachWait.SNK State
          A Sink shall transition to Unattached.SNK when the state of both
          the CC1 and CC2 pins is SNK.Open for at least tPDDebounce.
          A DRP shall transition to Unattached.SRC when the state of both
          the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."
      
      [23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected]
      [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS]
      [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS]
      [23.300579] VBUS off
      [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS]
      [23.301014] VBUS VSAFE0V
      [23.301111] Start toggling
      
      Fixes: f0690a25
      
       ("staging: typec: USB Type-C Port Manager (tcpm)")
      Cc: stable@vger.kernel.org
      Acked-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/20220122015520.332507-1-badhri@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3922b6e1
    • Alan Stern's avatar
      USB: core: Fix hang in usb_kill_urb by adding memory barriers · 9c61fce3
      Alan Stern authored
      commit 26fbe977
      
       upstream.
      
      The syzbot fuzzer has identified a bug in which processes hang waiting
      for usb_kill_urb() to return.  It turns out the issue is not unlinking
      the URB; that works just fine.  Rather, the problem arises when the
      wakeup notification that the URB has completed is not received.
      
      The reason is memory-access ordering on SMP systems.  In outline form,
      usb_kill_urb() and __usb_hcd_giveback_urb() operating concurrently on
      different CPUs perform the following actions:
      
      CPU 0					CPU 1
      ----------------------------		---------------------------------
      usb_kill_urb():				__usb_hcd_giveback_urb():
        ...					  ...
        atomic_inc(&urb->reject);		  atomic_dec(&urb->use_count);
        ...					  ...
        wait_event(usb_kill_urb_queue,
      	atomic_read(&urb->use_count) == 0);
      					  if (atomic_read(&urb->reject))
      						wake_up(&usb_kill_urb_queue);
      
      Confining your attention to urb->reject and urb->use_count, you can
      see that the overall pattern of accesses on CPU 0 is:
      
      	write urb->reject, then read urb->use_count;
      
      whereas the overall pattern of accesses on CPU 1 is:
      
      	write urb->use_count, then read urb->reject.
      
      This pattern is referred to in memory-model circles as SB (for "Store
      Buffering"), and it is well known that without suitable enforcement of
      the desired order of accesses -- in the form of memory barriers -- it
      is entirely possible for one or both CPUs to execute their reads ahead
      of their writes.  The end result will be that sometimes CPU 0 sees the
      old un-decremented value of urb->use_count while CPU 1 sees the old
      un-incremented value of urb->reject.  Consequently CPU 0 ends up on
      the wait queue and never gets woken up, leading to the observed hang
      in usb_kill_urb().
      
      The same pattern of accesses occurs in usb_poison_urb() and the
      failure pathway of usb_hcd_submit_urb().
      
      The problem is fixed by adding suitable memory barriers.  To provide
      proper memory-access ordering in the SB pattern, a full barrier is
      required on both CPUs.  The atomic_inc() and atomic_dec() accesses
      themselves don't provide any memory ordering, but since they are
      present, we can use the optimized smp_mb__after_atomic() memory
      barrier in the various routines to obtain the desired effect.
      
      This patch adds the necessary memory barriers.
      
      CC: <stable@vger.kernel.org>
      Reported-and-tested-by: default avatar <syzbot+76629376e06e2c2ad626@syzkaller.appspotmail.com>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/Ye8K0QYee0Q0Nna2@rowland.harvard.edu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c61fce3
    • Pavankumar Kondeti's avatar
      usb: gadget: f_sourcesink: Fix isoc transfer for USB_SPEED_SUPER_PLUS · 4fc6519b
      Pavankumar Kondeti authored
      commit 904edf8a upstream.
      
      Currently when gadget enumerates in super speed plus, the isoc
      endpoint request buffer size is not calculated correctly. Fix
      this by checking the gadget speed against USB_SPEED_SUPER_PLUS
      and update the request buffer size.
      
      Fixes: 90c4d057
      
       ("usb: fix various gadgets null ptr deref on 10gbps cabling.")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarPavankumar Kondeti <quic_pkondeti@quicinc.com>
      Link: https://lore.kernel.org/r/1642820602-20619-1-git-send-email-quic_pkondeti@quicinc.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fc6519b
    • Jon Hunter's avatar
      usb: common: ulpi: Fix crash in ulpi_match() · 64e671a2
      Jon Hunter authored
      commit 2e3dd4a6 upstream.
      
      Commit 7495af93 ("ARM: multi_v7_defconfig: Enable drivers for
      DragonBoard 410c") enables the CONFIG_PHY_QCOM_USB_HS for the ARM
      multi_v7_defconfig. Enabling this Kconfig is causing the kernel to crash
      on the Tegra20 Ventana platform in the ulpi_match() function.
      
      The Qualcomm USB HS PHY driver that is enabled by CONFIG_PHY_QCOM_USB_HS,
      registers a ulpi_driver but this driver does not provide an 'id_table',
      so when ulpi_match() is called on the Tegra20 Ventana platform, it
      crashes when attempting to deference the id_table pointer which is not
      valid. The Qualcomm USB HS PHY driver uses device-tree for matching the
      ULPI driver with the device and so fix this crash by using device-tree
      for matching if the id_table is not valid.
      
      Fixes: ef6a7bcf
      
       ("usb: ulpi: Support device discovery via DT")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Link: https://lore.kernel.org/r/20220117150039.44058-1-jonathanh@nvidia.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64e671a2
    • Alan Stern's avatar
      usb-storage: Add unusual-devs entry for VL817 USB-SATA bridge · d66dc656
      Alan Stern authored
      commit 5b67b315
      
       upstream.
      
      Two people have reported (and mentioned numerous other reports on the
      web) that VIA's VL817 USB-SATA bridge does not work with the uas
      driver.  Typical log messages are:
      
      [ 3606.232149] sd 14:0:0:0: [sdg] tag#2 uas_zap_pending 0 uas-tag 1 inflight: CMD
      [ 3606.232154] sd 14:0:0:0: [sdg] tag#2 CDB: Write(16) 8a 00 00 00 00 00 18 0c c9 80 00 00 00 80 00 00
      [ 3606.306257] usb 4-4.4: reset SuperSpeed Plus Gen 2x1 USB device number 11 using xhci_hcd
      [ 3606.328584] scsi host14: uas_eh_device_reset_handler success
      
      Surprisingly, the devices do seem to work okay for some other people.
      The cause of the differing behaviors is not known.
      
      In the hope of getting the devices to work for the most users, even at
      the possible cost of degraded performance for some, this patch adds an
      unusual_devs entry for the VL817 to block it from binding to the uas
      driver by default.  Users will be able to override this entry by means
      of a module parameter, if they want.
      
      CC: <stable@vger.kernel.org>
      Reported-by: default avatarDocMAX <mail@vacharakis.de>
      Reported-and-tested-by: default avatarThomas Weißschuh <linux@weissschuh.net>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/Ye8IsK2sjlEv1rqU@rowland.harvard.edu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d66dc656
    • Cameron Williams's avatar
      tty: Add support for Brainboxes UC cards. · a06cba5a
      Cameron Williams authored
      commit 152d1afa
      
       upstream.
      
      This commit adds support for the some of the Brainboxes PCI range of
      cards, including the UC-101, UC-235/246, UC-257, UC-268, UC-275/279,
      UC-302, UC-310, UC-313, UC-320/324, UC-346, UC-357, UC-368
      and UC-420/431.
      
      Signed-off-by: default avatarCameron Williams <cang1@live.co.uk>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/AM5PR0202MB2564688493F7DD9B9C610827C45E9@AM5PR0202MB2564.eurprd02.prod.outlook.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a06cba5a
    • daniel.starke@siemens.com's avatar
      tty: n_gsm: fix SW flow control encoding/handling · f5e6c946
      daniel.starke@siemens.com authored
      commit 8838b2af upstream.
      
      n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
      See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
      The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
      the newer 27.010 here. Chapter 5.2.7.3 states that DC1 (XON) and DC3 (XOFF)
      are the control characters defined in ISO/IEC 646. These shall be quoted if
      seen in the data stream to avoid interpretation as flow control characters.
      
      ISO/IEC 646 refers to the set of ISO standards described as the ISO
      7-bit coded character set for information interchange. Its final version
      is also known as ITU T.50.
      See https://www.itu.int/rec/T-REC-T.50-199209-I/en
      
      To abide the standard it is needed to quote DC1 and DC3 correctly if these
      are seen as data bytes and not as control characters. The current
      implementation already tries to enforce this but fails to catch all
      defined cases. 3GPP 27.010 chapter 5.2.7.3 clearly states that the most
      significant bit shall be ignored for DC1 and DC3 handling. The current
      implementation handles only the case with the most significant bit set 0.
      Cases in which DC1 and DC3 have the most significant bit set 1 are left
      unhandled.
      
      This patch fixes this by masking the data bytes with ISO_IEC_646_MASK (only
      the 7 least significant bits set 1) before comparing them with XON
      (a.k.a. DC1) and XOFF (a.k.a. DC3) when testing which byte values need
      quotation via byte stuffing.
      
      Fixes: e1eaea46
      
       ("tty: n_gsm line discipline")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDaniel Starke <daniel.starke@siemens.com>
      Link: https://lore.kernel.org/r/20220120101857.2509-1-daniel.starke@siemens.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5e6c946
    • Valentin Caron's avatar
      serial: stm32: fix software flow control transfer · 05b33011
      Valentin Caron authored
      commit 037b91ec upstream.
      
      x_char is ignored by stm32_usart_start_tx() when xmit buffer is empty.
      
      Fix start_tx condition to allow x_char to be sent.
      
      Fixes: 48a6092f
      
       ("serial: stm32-usart: Add STM32 USART Driver")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarErwan Le Ray <erwan.leray@foss.st.com>
      Signed-off-by: default avatarValentin Caron <valentin.caron@foss.st.com>
      Link: https://lore.kernel.org/r/20220111164441.6178-3-valentin.caron@foss.st.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05b33011
    • Robert Hancock's avatar
      serial: 8250: of: Fix mapped region size when using reg-offset property · 0b92eda2
      Robert Hancock authored
      commit d06b1cf2 upstream.
      
      8250_of supports a reg-offset property which is intended to handle
      cases where the device registers start at an offset inside the region
      of memory allocated to the device. The Xilinx 16550 UART, for which this
      support was initially added, requires this. However, the code did not
      adjust the overall size of the mapped region accordingly, causing the
      driver to request an area of memory past the end of the device's
      allocation. For example, if the UART was allocated an address of
      0xb0130000, size of 0x10000 and reg-offset of 0x1000 in the device
      tree, the region of memory reserved was b0131000-b0140fff, which caused
      the driver for the region starting at b0140000 to fail to probe.
      
      Fix this by subtracting reg-offset from the mapped region size.
      
      Fixes: b912b5e2
      
       ([POWERPC] Xilinx: of_serial support for Xilinx uart 16550.)
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
      Link: https://lore.kernel.org/r/20220112194214.881844-1-robert.hancock@calian.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0b92eda2
    • Pablo Neira Ayuso's avatar
      netfilter: nft_payload: do not update layer 4 checksum when mangling fragments · 2bf7dee6
      Pablo Neira Ayuso authored
      commit 4e1860a3 upstream.
      
      IP fragments do not come with the transport header, hence skip bogus
      layer 4 checksum updates.
      
      Fixes: 18140969
      
       ("netfilter: nft_payload: layer 4 checksum adjustment for pseudoheader fields")
      Reported-and-tested-by: default avatarSteffen Weinreich <steve@weinreich.org>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2bf7dee6
    • D Scott Phillips's avatar
      arm64: errata: Fix exec handling in erratum 1418040 workaround · a6d58857
      D Scott Phillips authored
      commit 38e0257e upstream.
      
      The erratum 1418040 workaround enables CNTVCT_EL1 access trapping in EL0
      when executing compat threads. The workaround is applied when switching
      between tasks, but the need for the workaround could also change at an
      exec(), when a non-compat task execs a compat binary or vice versa. Apply
      the workaround in arch_setup_new_exec().
      
      This leaves a small window of time between SET_PERSONALITY and
      arch_setup_new_exec where preemption could occur and confuse the old
      workaround logic that compares TIF_32BIT between prev and next. Instead, we
      can just read cntkctl to make sure it's in the state that the next task
      needs. I measured cntkctl read time to be about the same as a mov from a
      general-purpose register on N1. Update the workaround logic to examine the
      current value of cntkctl instead of the previous task's compat state.
      
      Fixes: d49f7d73
      
       ("arm64: Move handling of erratum 1418040 into C code")
      Cc: <stable@vger.kernel.org> # 5.9.x
      Signed-off-by: default avatarD Scott Phillips <scott@os.amperecomputing.com>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20211220234114.3926-1-scott@os.amperecomputing.com
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6d58857
    • Lucas Stach's avatar
      drm/etnaviv: relax submit size limits · 5cbcd1f5
      Lucas Stach authored
      commit e3d26528 upstream.
      
      While all userspace tried to limit commandstreams to 64K in size,
      a bug in the Mesa driver lead to command streams of up to 128K
      being submitted. Allow those to avoid breaking existing userspace.
      
      Fixes: 6dfa2fab
      
       ("drm/etnaviv: limit submit sizes")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Reviewed-by: default avatarChristian Gmeiner <christian.gmeiner@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5cbcd1f5
    • Amir Goldstein's avatar
      fsnotify: fix fsnotify hooks in pseudo filesystems · 5463cfd8
      Amir Goldstein authored
      commit 29044dae upstream.
      
      Commit 49246466 ("fsnotify: move fsnotify_nameremove() hook out of
      d_delete()") moved the fsnotify delete hook before d_delete() so fsnotify
      will have access to a positive dentry.
      
      This allowed a race where opening the deleted file via cached dentry
      is now possible after receiving the IN_DELETE event.
      
      To fix the regression in pseudo filesystems, convert d_delete() calls
      to d_drop() (see commit 46c46f8d
      
       ("devpts_pty_kill(): don't bother
      with d_delete()") and move the fsnotify hook after d_drop().
      
      Add a missing fsnotify_unlink() hook in nfsdfs that was found during
      the audit of fsnotify hooks in pseudo filesystems.
      
      Note that the fsnotify hooks in simple_recursive_removal() follow
      d_invalidate(), so they require no change.
      
      Link: https://lore.kernel.org/r/20220120215305.282577-2-amir73il@gmail.com
      Reported-by: default avatarIvan Delalande <colona@arista.com>
      Link: https://lore.kernel.org/linux-fsdevel/YeNyzoDM5hP5LtGW@visor/
      Fixes: 49246466
      
       ("fsnotify: move fsnotify_nameremove() hook out of d_delete()")
      Cc: stable@vger.kernel.org # v5.3+
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5463cfd8
    • Tom Zanussi's avatar
      tracing: Don't inc err_log entry count if entry allocation fails · 1614bd84
      Tom Zanussi authored
      commit 67ab5eb7 upstream.
      
      tr->n_err_log_entries should only be increased if entry allocation
      succeeds.
      
      Doing it when it fails won't cause any problems other than wasting an
      entry, but should be fixed anyway.
      
      Link: https://lkml.kernel.org/r/cad1ab28f75968db0f466925e7cba5970cec6c29.1643319703.git.zanussi@kernel.org
      
      Cc: stable@vger.kernel.org
      Fixes: 2f754e77
      
       ("tracing: Don't inc err_log entry count if entry allocation fails")
      Signed-off-by: default avatarTom Zanussi <zanussi@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1614bd84
    • Xiaoke Wang's avatar
      tracing/histogram: Fix a potential memory leak for kstrdup() · 8a8878eb
      Xiaoke Wang authored
      commit e629e7b5 upstream.
      
      kfree() is missing on an error path to free the memory allocated by
      kstrdup():
      
        p = param = kstrdup(data->params[i], GFP_KERNEL);
      
      So it is better to free it via kfree(p).
      
      Link: https://lkml.kernel.org/r/tencent_C52895FD37802832A3E5B272D05008866F0A@qq.com
      
      Cc: stable@vger.kernel.org
      Fixes: d380dcde
      
       ("tracing: Fix now invalid var_ref_vals assumption in trace action")
      Signed-off-by: default avatarXiaoke Wang <xkernel.wang@foxmail.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a8878eb
    • Greg Kroah-Hartman's avatar
      PM: wakeup: simplify the output logic of pm_show_wakelocks() · 73578a9b
      Greg Kroah-Hartman authored
      commit c9d967b2
      
       upstream.
      
      The buffer handling in pm_show_wakelocks() is tricky, and hopefully
      correct.  Ensure it really is correct by using sysfs_emit_at() which
      handles all of the tricky string handling logic in a PAGE_SIZE buffer
      for us automatically as this is a sysfs file being read from.
      
      Reviewed-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73578a9b
    • Jan Kara's avatar
      udf: Fix NULL ptr deref when converting from inline format · 31136e54
      Jan Kara authored
      commit 7fc3b7c2
      
       upstream.
      
      udf_expand_file_adinicb() calls directly ->writepage to write data
      expanded into a page. This however misses to setup inode for writeback
      properly and so we can crash on inode->i_wb dereference when submitting
      page for IO like:
      
        BUG: kernel NULL pointer dereference, address: 0000000000000158
        #PF: supervisor read access in kernel mode
      ...
        <TASK>
        __folio_start_writeback+0x2ac/0x350
        __block_write_full_page+0x37d/0x490
        udf_expand_file_adinicb+0x255/0x400 [udf]
        udf_file_write_iter+0xbe/0x1b0 [udf]
        new_sync_write+0x125/0x1c0
        vfs_write+0x28e/0x400
      
      Fix the problem by marking the page dirty and going through the standard
      writeback path to write the page. Strictly speaking we would not even
      have to write the page but we want to catch e.g. ENOSPC errors early.
      
      Reported-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
      CC: stable@vger.kernel.org
      Fixes: 52ebea74
      
       ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks")
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      31136e54
    • Jan Kara's avatar
      udf: Restore i_lenAlloc when inode expansion fails · 86bcc670
      Jan Kara authored
      commit ea856919
      
       upstream.
      
      When we fail to expand inode from inline format to a normal format, we
      restore inode to contain the original inline formatting but we forgot to
      set i_lenAlloc back. The mismatch between i_lenAlloc and i_size was then
      causing further problems such as warnings and lost data down the line.
      
      Reported-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
      CC: stable@vger.kernel.org
      Fixes: 7e49b6f2
      
       ("udf: Convert UDF to new truncate calling sequence")
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86bcc670
    • Steffen Maier's avatar
      scsi: zfcp: Fix failed recovery on gone remote port with non-NPIV FCP devices · c54445af
      Steffen Maier authored
      commit 8c9db667 upstream.
      
      Suppose we have an environment with a number of non-NPIV FCP devices
      (virtual HBAs / FCP devices / zfcp "adapter"s) sharing the same physical
      FCP channel (HBA port) and its I_T nexus. Plus a number of storage target
      ports zoned to such shared channel. Now one target port logs out of the
      fabric causing an RSCN. Zfcp reacts with an ADISC ELS and subsequent port
      recovery depending on the ADISC result. This happens on all such FCP
      devices (in different Linux images) concurrently as they all receive a copy
      of this RSCN. In the following we look at one of those FCP devices.
      
      Requests other than FSF_QTCB_FCP_CMND can be slow until they get a
      response.
      
      Depending on which requests are affected by slow responses, there are
      different recovery outcomes. Here we want to fix failed recoveries on port
      or adapter level by avoiding recovery requests that can be slow.
      
      We need the cached N_Port_ID for the remote port "link" test with ADISC.
      Just before sending the ADISC, we now intentionally forget the old cached
      N_Port_ID. The idea is that on receiving an RSCN for a port, we have to
      assume that any cached information about this port is stale.  This forces a
      fresh new GID_PN [FC-GS] nameserver lookup on any subsequent recovery for
      the same port. Since we typically can still communicate with the nameserver
      efficiently, we now reach steady state quicker: Either the nameserver still
      does not know about the port so we stop recovery, or the nameserver already
      knows the port potentially with a new N_Port_ID and we can successfully and
      quickly perform open port recovery.  For the one case, where ADISC returns
      successfully, we re-initialize port->d_id because that case does not
      involve any port recovery.
      
      This also solves a problem if the storage WWPN quickly logs into the fabric
      again but with a different N_Port_ID. Such as on virtual WWPN takeover
      during target NPIV failover.
      [https://www.redbooks.ibm.com/abstracts/redp5477.html] In that case the
      RSCN from the storage FDISC was ignored by zfcp and we could not
      successfully recover the failover. On some later failback on the storage,
      we could have been lucky if the virtual WWPN got the same old N_Port_ID
      from the SAN switch as we still had cached.  Then the related RSCN
      triggered a successful port reopen recovery.  However, there is no
      guarantee to get the same N_Port_ID on NPIV FDISC.
      
      Even though NPIV-enabled FCP devices are not affected by this problem, this
      code change optimizes recovery time for gone remote ports as a side effect.
      The timely drop of cached N_Port_IDs prevents unnecessary slow open port
      attempts.
      
      While the problem might have been in code before v2.6.32 commit
      799b76d0 ("[SCSI] zfcp: Decouple gid_pn requests from erp") this fix
      depends on the gid_pn_work introduced with that commit, so we mark it as
      culprit to satisfy fix dependencies.
      
      Note: Point-to-point remote port is already handled separately and gets its
      N_Port_ID from the cached peer_d_id. So resetting port->d_id in general
      does not affect PtP.
      
      Link: https://lore.kernel.org/r/20220118165803.3667947-1-maier@linux.ibm.com
      Fixes: 799b76d0
      
       ("[SCSI] zfcp: Decouple gid_pn requests from erp")
      Cc: <stable@vger.kernel.org> #2.6.32+
      Suggested-by: default avatarBenjamin Block <bblock@linux.ibm.com>
      Reviewed-by: default avatarBenjamin Block <bblock@linux.ibm.com>
      Signed-off-by: default avatarSteffen Maier <maier@linux.ibm.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c54445af
    • Vasily Gorbik's avatar
      s390/hypfs: include z/VM guests with access control group set · 4d041e75
      Vasily Gorbik authored
      commit 663d34c8 upstream.
      
      Currently if z/VM guest is allowed to retrieve hypervisor performance
      data globally for all guests (privilege class B) the query is formed in a
      way to include all guests but the group name is left empty. This leads to
      that z/VM guests which have access control group set not being included
      in the results (even local vm).
      
      Change the query group identifier from empty to "any" to retrieve
      information about all guests from any groups (or without a group set).
      
      Cc: stable@vger.kernel.org
      Fixes: 31cb4bd3
      
       ("[S390] Hypervisor filesystem (s390_hypfs) for z/VM")
      Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d041e75
    • Brian Gix's avatar
      Bluetooth: refactor malicious adv data check · 835d3706
      Brian Gix authored
      commit 899663be
      
       upstream.
      
      Check for out-of-bound read was being performed at the end of while
      num_reports loop, and would fill journal with false positives. Added
      check to beginning of loop processing so that it doesn't get checked
      after ptr has been advanced.
      
      Signed-off-by: default avatarBrian Gix <brian.gix@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Cc: syphyr <syphyr@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      835d3706
  2. Jan 29, 2022
  3. Jan 27, 2022