Skip to content
  1. Feb 02, 2022
    • Guenter Roeck's avatar
      hwmon: (lm90) Reduce maximum conversion rate for G781 · c27abaa0
      Guenter Roeck authored
      [ Upstream commit a66c5ed5 ]
      
      According to its datasheet, G781 supports a maximum conversion rate value
      of 8 (62.5 ms). However, chips labeled G781 and G780 were found to only
      support a maximum conversion rate value of 7 (125 ms). On the other side,
      chips labeled G781-1 and G784 were found to support a conversion rate value
      of 8. There is no known means to distinguish G780 from G781 or G784; all
      chips report the same manufacturer ID and chip revision.
      Setting the conversion rate register value to 8 on chips not supporting
      it causes unexpected behavior since the real conversion rate is set to 0
      (16 seconds) if a value of 8 is written into the conversion rate register.
      Limit the conversion rate register value to 7 for all G78x chips to avoid
      the problem.
      
      Fixes: ae544f64
      
       ("hwmon: (lm90) Add support for GMT G781")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c27abaa0
    • Eric Dumazet's avatar
      ipv4: avoid using shared IP generator for connected sockets · 1f748455
      Eric Dumazet authored
      commit 23f57406 upstream.
      
      ip_select_ident_segs() has been very conservative about using
      the connected socket private generator only for packets with IP_DF
      set, claiming it was needed for some VJ compression implementations.
      
      As mentioned in this referenced document, this can be abused.
      (Ref: Off-Path TCP Exploits of the Mixed IPID Assignment)
      
      Before switching to pure random IPID generation and possibly hurt
      some workloads, lets use the private inet socket generator.
      
      Not only this will remove one vulnerability, this will also
      improve performance of TCP flows using pmtudisc==IP_PMTUDISC_DONT
      
      Fixes: 73f156a6
      
       ("inetpeer: get rid of ip_id_count")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Reported-by: default avatarRay Che <xijiache@gmail.com>
      Cc: Willy Tarreau <w@1wt.eu>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f748455
    • Xin Long's avatar
      ping: fix the sk_bound_dev_if match in ping_lookup · ca535577
      Xin Long authored
      commit 2afc3b5a upstream.
      
      When 'ping' changes to use PING socket instead of RAW socket by:
      
         # sysctl -w net.ipv4.ping_group_range="0 100"
      
      the selftests 'router_broadcast.sh' will fail, as such command
      
        # ip vrf exec vrf-h1 ping -I veth0 198.51.100.255 -b
      
      can't receive the response skb by the PING socket. It's caused by mismatch
      of sk_bound_dev_if and dif in ping_rcv() when looking up the PING socket,
      as dif is vrf-h1 if dif's master was set to vrf-h1.
      
      This patch is to fix this regression by also checking the sk_bound_dev_if
      against sdif so that the packets can stil be received even if the socket
      is not bound to the vrf device but to the real iif.
      
      Fixes: c319b4d7
      
       ("net: ipv4: add IPPROTO_ICMP socket kind")
      Reported-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ca535577
    • Guenter Roeck's avatar
      hwmon: (lm90) Mark alert as broken for MAX6680 · 0b567a24
      Guenter Roeck authored
      commit 94746b0b upstream.
      
      Experiments with MAX6680 and MAX6681 show that the alert function of those
      chips is broken, similar to other chips supported by the lm90 driver.
      Mark it accordingly.
      
      Fixes: 4667bcb8
      
       ("hwmon: (lm90) Introduce chip parameter structure")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0b567a24
    • Guenter Roeck's avatar
      hwmon: (lm90) Mark alert as broken for MAX6646/6647/6649 · b6303165
      Guenter Roeck authored
      commit f614629f upstream.
      
      Experiments with MAX6646 and MAX6648 show that the alert function of those
      chips is broken, similar to other chips supported by the lm90 driver.
      Mark it accordingly.
      
      Fixes: 4667bcb8
      
       ("hwmon: (lm90) Introduce chip parameter structure")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b6303165
    • Congyu Liu's avatar
      net: fix information leakage in /proc/net/ptype · e372ecd4
      Congyu Liu authored
      commit 47934e06 upstream.
      
      In one net namespace, after creating a packet socket without binding
      it to a device, users in other net namespaces can observe the new
      `packet_type` added by this packet socket by reading `/proc/net/ptype`
      file. This is minor information leakage as packet socket is
      namespace aware.
      
      Add a net pointer in `packet_type` to keep the net namespace of
      of corresponding packet socket. In `ptype_seq_show`, this net pointer
      must be checked when it is not NULL.
      
      Fixes: 2feb27db
      
       ("[NETNS]: Minor information leak via /proc/net/ptype file.")
      Signed-off-by: default avatarCongyu Liu <liu3101@purdue.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e372ecd4
    • Ido Schimmel's avatar
      ipv6_tunnel: Rate limit warning messages · 20b7af41
      Ido Schimmel authored
      commit 6cee105e upstream.
      
      The warning messages can be invoked from the data path for every packet
      transmitted through an ip6gre netdev, leading to high CPU utilization.
      
      Fix that by rate limiting the messages.
      
      Fixes: 09c6bbf0
      
       ("[IPV6]: Do mandatory IPv6 tunnel endpoint checks in realtime")
      Reported-by: default avatarMaksym Yaremchuk <maksymy@nvidia.com>
      Tested-by: default avatarMaksym Yaremchuk <maksymy@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      20b7af41
    • John Meneghini's avatar
      scsi: bnx2fc: Flush destroy_work queue before calling bnx2fc_interface_put() · bf2bd892
      John Meneghini authored
      commit 847f9ea4 upstream.
      
      The bnx2fc_destroy() functions are removing the interface before calling
      destroy_work. This results multiple WARNings from sysfs_remove_group() as
      the controller rport device attributes are removed too early.
      
      Replace the fcoe_port's destroy_work queue. It's not needed.
      
      The problem is easily reproducible with the following steps.
      
      Example:
      
        $ dmesg -w &
        $ systemctl enable --now fcoe
        $ fipvlan -s -c ens2f1
        $ fcoeadm -d ens2f1.802
        [  583.464488] host2: libfc: Link down on port (7500a1)
        [  583.472651] bnx2fc: 7500a1 - rport not created Yet!!
        [  583.490468] ------------[ cut here ]------------
        [  583.538725] sysfs group 'power' not found for kobject 'rport-2:0-0'
        [  583.568814] WARNING: CPU: 3 PID: 192 at fs/sysfs/group.c:279 sysfs_remove_group+0x6f/0x80
        [  583.607130] Modules linked in: dm_service_time 8021q garp mrp stp llc bnx2fc cnic uio rpcsec_gss_krb5 auth_rpcgss nfsv4 ...
        [  583.942994] CPU: 3 PID: 192 Comm: kworker/3:2 Kdump: loaded Not tainted 5.14.0-39.el9.x86_64 #1
        [  583.984105] Hardware name: HP ProLiant DL120 G7, BIOS J01 07/01/2013
        [  584.016535] Workqueue: fc_wq_2 fc_rport_final_delete [scsi_transport_fc]
        [  584.050691] RIP: 0010:sysfs_remove_group+0x6f/0x80
        [  584.074725] Code: ff 5b 48 89 ef 5d 41 5c e9 ee c0 ff ff 48 89 ef e8 f6 b8 ff ff eb d1 49 8b 14 24 48 8b 33 48 c7 c7 ...
        [  584.162586] RSP: 0018:ffffb567c15afdc0 EFLAGS: 00010282
        [  584.188225] RAX: 0000000000000000 RBX: ffffffff8eec4220 RCX: 0000000000000000
        [  584.221053] RDX: ffff8c1586ce84c0 RSI: ffff8c1586cd7cc0 RDI: ffff8c1586cd7cc0
        [  584.255089] RBP: 0000000000000000 R08: 0000000000000000 R09: ffffb567c15afc00
        [  584.287954] R10: ffffb567c15afbf8 R11: ffffffff8fbe7f28 R12: ffff8c1486326400
        [  584.322356] R13: ffff8c1486326480 R14: ffff8c1483a4a000 R15: 0000000000000004
        [  584.355379] FS:  0000000000000000(0000) GS:ffff8c1586cc0000(0000) knlGS:0000000000000000
        [  584.394419] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [  584.421123] CR2: 00007fe95a6f7840 CR3: 0000000107674002 CR4: 00000000000606e0
        [  584.454888] Call Trace:
        [  584.466108]  device_del+0xb2/0x3e0
        [  584.481701]  device_unregister+0x13/0x60
        [  584.501306]  bsg_unregister_queue+0x5b/0x80
        [  584.522029]  bsg_remove_queue+0x1c/0x40
        [  584.541884]  fc_rport_final_delete+0xf3/0x1d0 [scsi_transport_fc]
        [  584.573823]  process_one_work+0x1e3/0x3b0
        [  584.592396]  worker_thread+0x50/0x3b0
        [  584.609256]  ? rescuer_thread+0x370/0x370
        [  584.628877]  kthread+0x149/0x170
        [  584.643673]  ? set_kthread_struct+0x40/0x40
        [  584.662909]  ret_from_fork+0x22/0x30
        [  584.680002] ---[ end trace 53575ecefa942ece ]---
      
      Link: https://lore.kernel.org/r/20220115040044.1013475-1-jmeneghi@redhat.com
      Fixes: 0cbf32e1
      
       ("[SCSI] bnx2fc: Avoid calling bnx2fc_if_destroy with unnecessary locks")
      Tested-by: default avatarGuangwu Zhang <guazhang@redhat.com>
      Co-developed-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Signed-off-by: default avatarJohn Meneghini <jmeneghi@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bf2bd892
    • Matthias Kaehlcke's avatar
      rpmsg: char: Fix race between the release of rpmsg_eptdev and cdev · d380beb5
      Matthias Kaehlcke authored
      commit 7a534ae8 upstream.
      
      struct rpmsg_eptdev contains a struct cdev. The current code frees
      the rpmsg_eptdev struct in rpmsg_eptdev_destroy(), but the cdev is
      a managed object, therefore its release is not predictable and the
      rpmsg_eptdev could be freed before the cdev is entirely released.
      
      The cdev_device_add/del() API was created to address this issue
      (see commit '233ed09d ("chardev: add helper function to register
      char devs with a struct device")'), use it instead of cdev add/del().
      
      Fixes: c0cdc19f
      
       ("rpmsg: Driver for user space endpoint interface")
      Suggested-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Link: https://lore.kernel.org/r/20220110104706.v6.2.Idde68b05b88d4a2e6e54766c653f3a6d9e419ce6@changeid
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d380beb5
    • Sujit Kautkar's avatar
      rpmsg: char: Fix race between the release of rpmsg_ctrldev and cdev · da27b834
      Sujit Kautkar authored
      commit b7fb2dad upstream.
      
      struct rpmsg_ctrldev contains a struct cdev. The current code frees
      the rpmsg_ctrldev struct in rpmsg_ctrldev_release_device(), but the
      cdev is a managed object, therefore its release is not predictable
      and the rpmsg_ctrldev could be freed before the cdev is entirely
      released, as in the backtrace below.
      
      [   93.625603] ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x7c
      [   93.636115] WARNING: CPU: 0 PID: 12 at lib/debugobjects.c:488 debug_print_object+0x13c/0x1b0
      [   93.644799] Modules linked in: veth xt_cgroup xt_MASQUERADE rfcomm algif_hash algif_skcipher af_alg uinput ip6table_nat fuse uvcvideo videobuf2_vmalloc venus_enc venus_dec videobuf2_dma_contig hci_uart btandroid btqca snd_soc_rt5682_i2c bluetooth qcom_spmi_temp_alarm snd_soc_rt5682v
      [   93.715175] CPU: 0 PID: 12 Comm: kworker/0:1 Tainted: G    B             5.4.163-lockdep #26
      [   93.723855] Hardware name: Google Lazor (rev3 - 8) with LTE (DT)
      [   93.730055] Workqueue: events kobject_delayed_cleanup
      [   93.735271] pstate: 60c00009 (nZCv daif +PAN +UAO)
      [   93.740216] pc : debug_print_object+0x13c/0x1b0
      [   93.744890] lr : debug_print_object+0x13c/0x1b0
      [   93.749555] sp : ffffffacf5bc7940
      [   93.752978] x29: ffffffacf5bc7940 x28: dfffffd000000000
      [   93.758448] x27: ffffffacdb11a800 x26: dfffffd000000000
      [   93.763916] x25: ffffffd0734f856c x24: dfffffd000000000
      [   93.769389] x23: 0000000000000000 x22: ffffffd0733c35b0
      [   93.774860] x21: ffffffd0751994a0 x20: ffffffd075ec27c0
      [   93.780338] x19: ffffffd075199100 x18: 00000000000276e0
      [   93.785814] x17: 0000000000000000 x16: dfffffd000000000
      [   93.791291] x15: ffffffffffffffff x14: 6e6968207473696c
      [   93.796768] x13: 0000000000000000 x12: ffffffd075e2b000
      [   93.802244] x11: 0000000000000001 x10: 0000000000000000
      [   93.807723] x9 : d13400dff1921900 x8 : d13400dff1921900
      [   93.813200] x7 : 0000000000000000 x6 : 0000000000000000
      [   93.818676] x5 : 0000000000000080 x4 : 0000000000000000
      [   93.824152] x3 : ffffffd0732a0fa4 x2 : 0000000000000001
      [   93.829628] x1 : ffffffacf5bc7580 x0 : 0000000000000061
      [   93.835104] Call trace:
      [   93.837644]  debug_print_object+0x13c/0x1b0
      [   93.841963]  __debug_check_no_obj_freed+0x25c/0x3c0
      [   93.846987]  debug_check_no_obj_freed+0x18/0x20
      [   93.851669]  slab_free_freelist_hook+0xbc/0x1e4
      [   93.856346]  kfree+0xfc/0x2f4
      [   93.859416]  rpmsg_ctrldev_release_device+0x78/0xb8
      [   93.864445]  device_release+0x84/0x168
      [   93.868310]  kobject_cleanup+0x12c/0x298
      [   93.872356]  kobject_delayed_cleanup+0x10/0x18
      [   93.876948]  process_one_work+0x578/0x92c
      [   93.881086]  worker_thread+0x804/0xcf8
      [   93.884963]  kthread+0x2a8/0x314
      [   93.888303]  ret_from_fork+0x10/0x18
      
      The cdev_device_add/del() API was created to address this issue (see
      commit '233ed09d ("chardev: add helper function to register char
      devs with a struct device")'), use it instead of cdev add/del().
      
      Fixes: c0cdc19f
      
       ("rpmsg: Driver for user space endpoint interface")
      Signed-off-by: default avatarSujit Kautkar <sujitka@chromium.org>
      Signed-off-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Link: https://lore.kernel.org/r/20220110104706.v6.1.Iaac908f3e3149a89190ce006ba166e2d3fd247a3@changeid
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      da27b834
    • Joe Damato's avatar
      i40e: fix unsigned stat widths · cb24af19
      Joe Damato authored
      commit 3b8428b8 upstream.
      
      Change i40e_update_vsi_stats and struct i40e_vsi to use u64 fields to match
      the width of the stats counters in struct i40e_rx_queue_stats.
      
      Update debugfs code to use the correct format specifier for u64.
      
      Fixes: 41c445ff
      
       ("i40e: main driver core")
      Signed-off-by: default avatarJoe Damato <jdamato@fastly.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb24af19
    • Sylwester Dziedziuch's avatar
      i40e: Fix queues reservation for XDP · be6998f2
      Sylwester Dziedziuch authored
      commit 92947844 upstream.
      
      When XDP was configured on a system with large number of CPUs
      and X722 NIC there was a call trace with NULL pointer dereference.
      
      i40e 0000:87:00.0: failed to get tracking for 256 queues for VSI 0 err -12
      i40e 0000:87:00.0: setup of MAIN VSI failed
      
      BUG: kernel NULL pointer dereference, address: 0000000000000000
      RIP: 0010:i40e_xdp+0xea/0x1b0 [i40e]
      Call Trace:
      ? i40e_reconfig_rss_queues+0x130/0x130 [i40e]
      dev_xdp_install+0x61/0xe0
      dev_xdp_attach+0x18a/0x4c0
      dev_change_xdp_fd+0x1e6/0x220
      do_setlink+0x616/0x1030
      ? ahci_port_stop+0x80/0x80
      ? ata_qc_issue+0x107/0x1e0
      ? lock_timer_base+0x61/0x80
      ? __mod_timer+0x202/0x380
      rtnl_setlink+0xe5/0x170
      ? bpf_lsm_binder_transaction+0x10/0x10
      ? security_capable+0x36/0x50
      rtnetlink_rcv_msg+0x121/0x350
      ? rtnl_calcit.isra.0+0x100/0x100
      netlink_rcv_skb+0x50/0xf0
      netlink_unicast+0x1d3/0x2a0
      netlink_sendmsg+0x22a/0x440
      sock_sendmsg+0x5e/0x60
      __sys_sendto+0xf0/0x160
      ? __sys_getsockname+0x7e/0xc0
      ? _copy_from_user+0x3c/0x80
      ? __sys_setsockopt+0xc8/0x1a0
      __x64_sys_sendto+0x20/0x30
      do_syscall_64+0x33/0x40
      entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f83fa7a39e0
      
      This was caused by PF queue pile fragmentation due to
      flow director VSI queue being placed right after main VSI.
      Because of this main VSI was not able to resize its
      queue allocation for XDP resulting in no queues allocated
      for main VSI when XDP was turned on.
      
      Fix this by always allocating last queue in PF queue pile
      for a flow director VSI.
      
      Fixes: 41c445ff ("i40e: main driver core")
      Fixes: 74608d17
      
       ("i40e: add support for XDP_TX action")
      Signed-off-by: default avatarSylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
      Signed-off-by: default avatarMateusz Palczewski <mateusz.palczewski@intel.com>
      Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Tested-by: default avatarKiran Bhandare <kiranx.bhandare@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be6998f2
    • Jedrzej Jagielski's avatar
      i40e: Fix issue when maximum queues is exceeded · b16f1a07
      Jedrzej Jagielski authored
      commit d701658a upstream.
      
      Before this patch VF interface vanished when
      maximum queue number was exceeded. Driver tried
      to add next queues even if there was not enough
      space. PF sent incorrect number of queues to
      the VF when there were not enough of them.
      
      Add an additional condition introduced to check
      available space in 'qp_pile' before proceeding.
      This condition makes it impossible to add queues
      if they number is greater than the number resulting
      from available space.
      Also add the search for free space in PF queue
      pair piles.
      
      Without this patch VF interfaces are not seen
      when available space for queues has been
      exceeded and following logs appears permanently
      in dmesg:
      "Unable to get VF config (-32)".
      "VF 62 failed opcode 3, retval: -5"
      "Unable to get VF config due to PF error condition, not retrying"
      
      Fixes: 7daa6bf3 ("i40e: driver core headers")
      Fixes: 41c445ff
      
       ("i40e: main driver core")
      Signed-off-by: default avatarJaroslaw Gawin <jaroslawx.gawin@intel.com>
      Signed-off-by: default avatarSlawomir Laba <slawomirx.laba@intel.com>
      Signed-off-by: default avatarJedrzej Jagielski <jedrzej.jagielski@intel.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b16f1a07
    • Jedrzej Jagielski's avatar
      i40e: Increase delay to 1 s after global EMP reset · f18aadbd
      Jedrzej Jagielski authored
      commit 9b13bd53 upstream.
      
      Recently simplified i40e_rebuild causes that FW sometimes
      is not ready after NVM update, the ping does not return.
      
      Increase the delay in case of EMP reset.
      Old delay of 300 ms was introduced for specific cards for 710 series.
      Now it works for all the cards and delay was increased.
      
      Fixes: 1fa51a65
      
       ("i40e: Add delay after EMP reset for firmware to recover")
      Signed-off-by: default avatarArkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
      Signed-off-by: default avatarJedrzej Jagielski <jedrzej.jagielski@intel.com>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f18aadbd
    • 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