Skip to content
  1. Aug 26, 2021
    • Thomas Gleixner's avatar
      PCI/MSI: Correct misleading comments · 73a00b00
      Thomas Gleixner authored
      commit 689e6b53
      
       upstream.
      
      The comments about preserving the cached state in pci_msi[x]_shutdown() are
      misleading as the MSI descriptors are freed right after those functions
      return. So there is nothing to restore. Preparatory change.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.621609423@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73a00b00
    • Thomas Gleixner's avatar
      PCI/MSI: Do not set invalid bits in MSI mask · 4e1ec390
      Thomas Gleixner authored
      commit 361fd373 upstream.
      
      msi_mask_irq() takes a mask and a flags argument. The mask argument is used
      to mask out bits from the cached mask and the flags argument to set bits.
      
      Some places invoke it with a flags argument which sets bits which are not
      used by the device, i.e. when the device supports up to 8 vectors a full
      unmask in some places sets the mask to 0xFFFFFF00. While devices probably
      do not care, it's still bad practice.
      
      Fixes: 7ba1930d
      
       ("PCI MSI: Unmask MSI if setup failed")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.568173099@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e1ec390
    • Thomas Gleixner's avatar
      PCI/MSI: Enable and mask MSI-X early · 130b04af
      Thomas Gleixner authored
      commit 43855395 upstream.
      
      The ordering of MSI-X enable in hardware is dysfunctional:
      
       1) MSI-X is disabled in the control register
       2) Various setup functions
       3) pci_msi_setup_msi_irqs() is invoked which ends up accessing
          the MSI-X table entries
       4) MSI-X is enabled and masked in the control register with the
          comment that enabling is required for some hardware to access
          the MSI-X table
      
      Step #4 obviously contradicts #3. The history of this is an issue with the
      NIU hardware. When #4 was introduced the table access actually happened in
      msix_program_entries() which was invoked after enabling and masking MSI-X.
      
      This was changed in commit d71d6432 ("PCI/MSI: Kill redundant call of
      irq_set_msi_desc() for MSI-X interrupts") which removed the table write
      from msix_program_entries().
      
      Interestingly enough nobody noticed and either NIU still works or it did
      not get any testing with a kernel 3.19 or later.
      
      Nevertheless this is inconsistent and there is no reason why MSI-X can't be
      enabled and masked in the control register early on, i.e. move step #4
      above to step #1. This preserves the NIU workaround and has no side effects
      on other hardware.
      
      Fixes: d71d6432
      
       ("PCI/MSI: Kill redundant call of irq_set_msi_desc() for MSI-X interrupts")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarAshok Raj <ashok.raj@intel.com>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.344136412@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      130b04af
    • Randy Dunlap's avatar
      x86/tools: Fix objdump version check again · 5fe8555c
      Randy Dunlap authored
      [ Upstream commit 839ad22f ]
      
      Skip (omit) any version string info that is parenthesized.
      
      Warning: objdump version 15) is older than 2.19
      Warning: Skipping posttest.
      
      where 'objdump -v' says:
      GNU objdump (GNU Binutils; SUSE Linux Enterprise 15) 2.35.1.20201123-7.18
      
      Fixes: 8bee738b
      
       ("x86: Fix objdump version check in chkobjdump.awk for different formats.")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Link: https://lore.kernel.org/r/20210731000146.2720-1-rdunlap@infradead.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5fe8555c
    • Maximilian Heyne's avatar
      xen/events: Fix race in set_evtchn_to_irq · e746e331
      Maximilian Heyne authored
      [ Upstream commit 88ca2521
      
       ]
      
      There is a TOCTOU issue in set_evtchn_to_irq. Rows in the evtchn_to_irq
      mapping are lazily allocated in this function. The check whether the row
      is already present and the row initialization is not synchronized. Two
      threads can at the same time allocate a new row for evtchn_to_irq and
      add the irq mapping to the their newly allocated row. One thread will
      overwrite what the other has set for evtchn_to_irq[row] and therefore
      the irq mapping is lost. This will trigger a BUG_ON later in
      bind_evtchn_to_cpu:
      
        INFO: pci 0000:1a:15.4: [1d0f:8061] type 00 class 0x010802
        INFO: nvme 0000:1a:12.1: enabling device (0000 -> 0002)
        INFO: nvme nvme77: 1/0/0 default/read/poll queues
        CRIT: kernel BUG at drivers/xen/events/events_base.c:427!
        WARN: invalid opcode: 0000 [#1] SMP NOPTI
        WARN: Workqueue: nvme-reset-wq nvme_reset_work [nvme]
        WARN: RIP: e030:bind_evtchn_to_cpu+0xc2/0xd0
        WARN: Call Trace:
        WARN:  set_affinity_irq+0x121/0x150
        WARN:  irq_do_set_affinity+0x37/0xe0
        WARN:  irq_setup_affinity+0xf6/0x170
        WARN:  irq_startup+0x64/0xe0
        WARN:  __setup_irq+0x69e/0x740
        WARN:  ? request_threaded_irq+0xad/0x160
        WARN:  request_threaded_irq+0xf5/0x160
        WARN:  ? nvme_timeout+0x2f0/0x2f0 [nvme]
        WARN:  pci_request_irq+0xa9/0xf0
        WARN:  ? pci_alloc_irq_vectors_affinity+0xbb/0x130
        WARN:  queue_request_irq+0x4c/0x70 [nvme]
        WARN:  nvme_reset_work+0x82d/0x1550 [nvme]
        WARN:  ? check_preempt_wakeup+0x14f/0x230
        WARN:  ? check_preempt_curr+0x29/0x80
        WARN:  ? nvme_irq_check+0x30/0x30 [nvme]
        WARN:  process_one_work+0x18e/0x3c0
        WARN:  worker_thread+0x30/0x3a0
        WARN:  ? process_one_work+0x3c0/0x3c0
        WARN:  kthread+0x113/0x130
        WARN:  ? kthread_park+0x90/0x90
        WARN:  ret_from_fork+0x3a/0x50
      
      This patch sets evtchn_to_irq rows via a cmpxchg operation so that they
      will be set only once. The row is now cleared before writing it to
      evtchn_to_irq in order to not create a race once the row is visible for
      other threads.
      
      While at it, do not require the page to be zeroed, because it will be
      overwritten with -1's in clear_evtchn_to_irq_row anyway.
      
      Signed-off-by: default avatarMaximilian Heyne <mheyne@amazon.de>
      Fixes: d0b075ff
      
       ("xen/events: Refactor evtchn_to_irq array to be dynamically allocated")
      Link: https://lore.kernel.org/r/20210812130930.127134-1-mheyne@amazon.de
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e746e331
    • Neal Cardwell's avatar
      tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets · 347bebf7
      Neal Cardwell authored
      [ Upstream commit 6de035fe ]
      
      Currently if BBR congestion control is initialized after more than 2B
      packets have been delivered, depending on the phase of the
      tp->delivered counter the tracking of BBR round trips can get stuck.
      
      The bug arises because if tp->delivered is between 2^31 and 2^32 at
      the time the BBR congestion control module is initialized, then the
      initialization of bbr->next_rtt_delivered to 0 will cause the logic to
      believe that the end of the round trip is still billions of packets in
      the future. More specifically, the following check will fail
      repeatedly:
      
        !before(rs->prior_delivered, bbr->next_rtt_delivered)
      
      and thus the connection will take up to 2B packets delivered before
      that check will pass and the connection will set:
      
        bbr->round_start = 1;
      
      This could cause many mechanisms in BBR to fail to trigger, for
      example bbr_check_full_bw_reached() would likely never exit STARTUP.
      
      This bug is 5 years old and has not been observed, and as a practical
      matter this would likely rarely trigger, since it would require
      transferring at least 2B packets, or likely more than 3 terabytes of
      data, before switching congestion control algorithms to BBR.
      
      This patch is a stable candidate for kernels as far back as v4.9,
      when tcp_bbr.c was added.
      
      Fixes: 0f8782ea
      
       ("tcp_bbr: add BBR congestion control")
      Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
      Reviewed-by: default avatarYuchung Cheng <ycheng@google.com>
      Reviewed-by: default avatarKevin Yang <yyd@google.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20210811024056.235161-1-ncardwell@google.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      347bebf7
    • Yang Yingliang's avatar
      net: bridge: fix memleak in br_add_if() · 59ef9eb1
      Yang Yingliang authored
      [ Upstream commit 519133de ]
      
      I got a memleak report:
      
      BUG: memory leak
      unreferenced object 0x607ee521a658 (size 240):
      comm "syz-executor.0", pid 955, jiffies 4294780569 (age 16.449s)
      hex dump (first 32 bytes, cpu 1):
      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
      backtrace:
      [<00000000d830ea5a>] br_multicast_add_port+0x1c2/0x300 net/bridge/br_multicast.c:1693
      [<00000000274d9a71>] new_nbp net/bridge/br_if.c:435 [inline]
      [<00000000274d9a71>] br_add_if+0x670/0x1740 net/bridge/br_if.c:611
      [<0000000012ce888e>] do_set_master net/core/rtnetlink.c:2513 [inline]
      [<0000000012ce888e>] do_set_master+0x1aa/0x210 net/core/rtnetlink.c:2487
      [<0000000099d1cafc>] __rtnl_newlink+0x1095/0x13e0 net/core/rtnetlink.c:3457
      [<00000000a01facc0>] rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3488
      [<00000000acc9186c>] rtnetlink_rcv_msg+0x369/0xa10 net/core/rtnetlink.c:5550
      [<00000000d4aabb9c>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504
      [<00000000bc2e12a3>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
      [<00000000bc2e12a3>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340
      [<00000000e4dc2d0e>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929
      [<000000000d22c8b3>] sock_sendmsg_nosec net/socket.c:654 [inline]
      [<000000000d22c8b3>] sock_sendmsg+0x139/0x170 net/socket.c:674
      [<00000000e281417a>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350
      [<00000000237aa2ab>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404
      [<000000004f2dc381>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433
      [<0000000005feca6c>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47
      [<000000007304477d>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      On error path of br_add_if(), p->mcast_stats allocated in
      new_nbp() need be freed, or it will be leaked.
      
      Fixes: 1080ab95
      
       ("net: bridge: add support for IGMP/MLD stats and export them via netlink")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Acked-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
      Link: https://lore.kernel.org/r/20210809132023.978546-1-yangyingliang@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      59ef9eb1
    • Takeshi Misawa's avatar
      net: Fix memory leak in ieee802154_raw_deliver · 2d661ed3
      Takeshi Misawa authored
      [ Upstream commit 1090340f ]
      
      If IEEE-802.15.4-RAW is closed before receive skb, skb is leaked.
      Fix this, by freeing sk_receive_queue in sk->sk_destruct().
      
      syzbot report:
      BUG: memory leak
      unreferenced object 0xffff88810f644600 (size 232):
        comm "softirq", pid 0, jiffies 4294967032 (age 81.270s)
        hex dump (first 32 bytes):
          10 7d 4b 12 81 88 ff ff 10 7d 4b 12 81 88 ff ff  .}K......}K.....
          00 00 00 00 00 00 00 00 40 7c 4b 12 81 88 ff ff  ........@|K.....
        backtrace:
          [<ffffffff83651d4a>] skb_clone+0xaa/0x2b0 net/core/skbuff.c:1496
          [<ffffffff83fe1b80>] ieee802154_raw_deliver net/ieee802154/socket.c:369 [inline]
          [<ffffffff83fe1b80>] ieee802154_rcv+0x100/0x340 net/ieee802154/socket.c:1070
          [<ffffffff8367cc7a>] __netif_receive_skb_one_core+0x6a/0xa0 net/core/dev.c:5384
          [<ffffffff8367cd07>] __netif_receive_skb+0x27/0xa0 net/core/dev.c:5498
          [<ffffffff8367cdd9>] netif_receive_skb_internal net/core/dev.c:5603 [inline]
          [<ffffffff8367cdd9>] netif_receive_skb+0x59/0x260 net/core/dev.c:5662
          [<ffffffff83fe6302>] ieee802154_deliver_skb net/mac802154/rx.c:29 [inline]
          [<ffffffff83fe6302>] ieee802154_subif_frame net/mac802154/rx.c:102 [inline]
          [<ffffffff83fe6302>] __ieee802154_rx_handle_packet net/mac802154/rx.c:212 [inline]
          [<ffffffff83fe6302>] ieee802154_rx+0x612/0x620 net/mac802154/rx.c:284
          [<ffffffff83fe59a6>] ieee802154_tasklet_handler+0x86/0xa0 net/mac802154/main.c:35
          [<ffffffff81232aab>] tasklet_action_common.constprop.0+0x5b/0x100 kernel/softirq.c:557
          [<ffffffff846000bf>] __do_softirq+0xbf/0x2ab kernel/softirq.c:345
          [<ffffffff81232f4c>] do_softirq kernel/softirq.c:248 [inline]
          [<ffffffff81232f4c>] do_softirq+0x5c/0x80 kernel/softirq.c:235
          [<ffffffff81232fc1>] __local_bh_enable_ip+0x51/0x60 kernel/softirq.c:198
          [<ffffffff8367a9a4>] local_bh_enable include/linux/bottom_half.h:32 [inline]
          [<ffffffff8367a9a4>] rcu_read_unlock_bh include/linux/rcupdate.h:745 [inline]
          [<ffffffff8367a9a4>] __dev_queue_xmit+0x7f4/0xf60 net/core/dev.c:4221
          [<ffffffff83fe2db4>] raw_sendmsg+0x1f4/0x2b0 net/ieee802154/socket.c:295
          [<ffffffff8363af16>] sock_sendmsg_nosec net/socket.c:654 [inline]
          [<ffffffff8363af16>] sock_sendmsg+0x56/0x80 net/socket.c:674
          [<ffffffff8363deec>] __sys_sendto+0x15c/0x200 net/socket.c:1977
          [<ffffffff8363dfb6>] __do_sys_sendto net/socket.c:1989 [inline]
          [<ffffffff8363dfb6>] __se_sys_sendto net/socket.c:1985 [inline]
          [<ffffffff8363dfb6>] __x64_sys_sendto+0x26/0x30 net/socket.c:1985
      
      Fixes: 9ec76716
      
       ("net: add IEEE 802.15.4 socket family implementation")
      Reported-and-tested-by: default avatar <syzbot+1f68113fa907bf0695a8@syzkaller.appspotmail.com>
      Signed-off-by: default avatarTakeshi Misawa <jeliantsurux@gmail.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20210805075414.GA15796@DESKTOP
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2d661ed3
    • Pali Rohár's avatar
      ppp: Fix generating ifname when empty IFLA_IFNAME is specified · 2aef926c
      Pali Rohár authored
      [ Upstream commit 2459dcb9
      
       ]
      
      IFLA_IFNAME is nul-term string which means that IFLA_IFNAME buffer can be
      larger than length of string which contains.
      
      Function __rtnl_newlink() generates new own ifname if either IFLA_IFNAME
      was not specified at all or userspace passed empty nul-term string.
      
      It is expected that if userspace does not specify ifname for new ppp netdev
      then kernel generates one in format "ppp<id>" where id matches to the ppp
      unit id which can be later obtained by PPPIOCGUNIT ioctl.
      
      And it works in this way if IFLA_IFNAME is not specified at all. But it
      does not work when IFLA_IFNAME is specified with empty string.
      
      So fix this logic also for empty IFLA_IFNAME in ppp_nl_newlink() function
      and correctly generates ifname based on ppp unit identifier if userspace
      did not provided preferred ifname.
      
      Without this patch when IFLA_IFNAME was specified with empty string then
      kernel created a new ppp interface in format "ppp<id>" but id did not
      match ppp unit id returned by PPPIOCGUNIT ioctl. In this case id was some
      number generated by __rtnl_newlink() function.
      
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Fixes: bb8082f6
      
       ("ppp: build ifname using unit identifier for rtnl based devices")
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2aef926c
    • Dan Williams's avatar
      ACPI: NFIT: Fix support for virtual SPA ranges · b8f4f546
      Dan Williams authored
      commit b93dfa6b upstream.
      
      Fix the NFIT parsing code to treat a 0 index in a SPA Range Structure as
      a special case and not match Region Mapping Structures that use 0 to
      indicate that they are not mapped. Without this fix some platform BIOS
      descriptions of "virtual disk" ranges do not result in the pmem driver
      attaching to the range.
      
      Details:
      In addition to typical persistent memory ranges, the ACPI NFIT may also
      convey "virtual" ranges. These ranges are indicated by a UUID in the SPA
      Range Structure of UUID_VOLATILE_VIRTUAL_DISK, UUID_VOLATILE_VIRTUAL_CD,
      UUID_PERSISTENT_VIRTUAL_DISK, or UUID_PERSISTENT_VIRTUAL_CD. The
      critical difference between virtual ranges and UUID_PERSISTENT_MEMORY,
      is that virtual do not support associations with Region Mapping
      Structures.  For this reason the "index" value of virtual SPA Range
      Structures is allowed to be 0. If a platform BIOS decides to represent
      NVDIMMs with disconnected "Region Mapping Structures" (range-index ==
      0), the kernel may falsely associate them with standalone ranges where
      the "SPA Range Structure Index" is also zero. When this happens the
      driver may falsely require labels where "virtual disks" are expected to
      be label-less. I.e. "label-less" is where the namespace-range ==
      region-range and the pmem driver attaches with no user action to create
      a namespace.
      
      Cc: Jacek Zloch <jacek.zloch@intel.com>
      Cc: Lukasz Sobieraj <lukasz.sobieraj@intel.com>
      Cc: "Lee, Chun-Yi" <jlee@suse.com>
      Cc: <stable@vger.kernel.org>
      Fixes: c2f32acd
      
       ("acpi, nfit: treat virtual ramdisk SPA as pmem region")
      Reported-by: default avatarKrzysztof Rusocki <krzysztof.rusocki@intel.com>
      Reported-by: default avatarDamian Bassa <damian.bassa@intel.com>
      Reviewed-by: default avatarJeff Moyer <jmoyer@redhat.com>
      Link: https://lore.kernel.org/r/162870796589.2521182.1240403310175570220.stgit@dwillia2-desk3.amr.corp.intel.com
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8f4f546
    • Greg Kroah-Hartman's avatar
      i2c: dev: zero out array used for i2c reads from userspace · bc42bd90
      Greg Kroah-Hartman authored
      commit 86ff25ed
      
       upstream.
      
      If an i2c driver happens to not provide the full amount of data that a
      user asks for, it is possible that some uninitialized data could be sent
      to userspace.  While all in-kernel drivers look to be safe, just be sure
      by initializing the buffer to zero before it is passed to the i2c driver
      so that any future drivers will not have this issue.
      
      Also properly copy the amount of data recvieved to the userspace buffer,
      as pointed out by Dan Carpenter.
      
      Reported-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc42bd90
    • Takashi Iwai's avatar
      ASoC: intel: atom: Fix reference to PCM buffer address · 642b0c74
      Takashi Iwai authored
      commit 2e6b8363
      
       upstream.
      
      PCM buffers might be allocated dynamically when the buffer
      preallocation failed or a larger buffer is requested, and it's not
      guaranteed that substream->dma_buffer points to the actually used
      buffer.  The address should be retrieved from runtime->dma_addr,
      instead of substream->dma_buffer (and shouldn't use virt_to_phys).
      
      Also, remove the line overriding runtime->dma_area superfluously,
      which was already set up at the PCM buffer allocation.
      
      Cc: Cezary Rojewski <cezary.rojewski@intel.com>
      Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Link: https://lore.kernel.org/r/20210728112353.6675-3-tiwai@suse.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      642b0c74
    • Colin Ian King's avatar
      iio: adc: Fix incorrect exit of for-loop · 9a057162
      Colin Ian King authored
      commit 5afc1540 upstream.
      
      Currently the for-loop that scans for the optimial adc_period iterates
      through all the possible adc_period levels because the exit logic in
      the loop is inverted. I believe the comparison should be swapped and
      the continue replaced with a break to exit the loop at the correct
      point.
      
      Addresses-Coverity: ("Continue has no effect")
      Fixes: e08e19c3
      
       ("iio:adc: add iio driver for Palmas (twl6035/7) gpadc")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Link: https://lore.kernel.org/r/20210730071651.17394-1-colin.king@canonical.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>
      9a057162
  2. Aug 15, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.9.280 · 89a3a5a5
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20210813150522.445553924@linuxfoundation.org
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.9.280
      89a3a5a5
    • Miklos Szeredi's avatar
      ovl: prevent private clone if bind mount is not allowed · e3eee87c
      Miklos Szeredi authored
      commit 427215d8
      
       upstream.
      
      Add the following checks from __do_loopback() to clone_private_mount() as
      well:
      
       - verify that the mount is in the current namespace
      
       - verify that there are no locked children
      
      Reported-by: default avatarAlois Wohlschlager <alois1@gmx-topmail.de>
      Fixes: c771d683
      
       ("vfs: introduce clone_private_mount()")
      Cc: <stable@vger.kernel.org> # v3.18
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3eee87c
    • YueHaibing's avatar
      net: xilinx_emaclite: Do not print real IOMEM pointer · ffdc1e31
      YueHaibing authored
      commit d0d62baa
      
       upstream.
      
      Printing kernel pointers is discouraged because they might leak kernel
      memory layout.  This fixes smatch warning:
      
      drivers/net/ethernet/xilinx/xilinx_emaclite.c:1191 xemaclite_of_probe() warn:
       argument 4 to %08lX specifier is cast from pointer
      
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffdc1e31
    • Pali Rohár's avatar
      ppp: Fix generating ppp unit id when ifname is not specified · dee5b011
      Pali Rohár authored
      commit 3125f26c
      
       upstream.
      
      When registering new ppp interface via PPPIOCNEWUNIT ioctl then kernel has
      to choose interface name as this ioctl API does not support specifying it.
      
      Kernel in this case register new interface with name "ppp<id>" where <id>
      is the ppp unit id, which can be obtained via PPPIOCGUNIT ioctl. This
      applies also in the case when registering new ppp interface via rtnl
      without supplying IFLA_IFNAME.
      
      PPPIOCNEWUNIT ioctl allows to specify own ppp unit id which will kernel
      assign to ppp interface, in case this ppp id is not already used by other
      ppp interface.
      
      In case user does not specify ppp unit id then kernel choose the first free
      ppp unit id. This applies also for case when creating ppp interface via
      rtnl method as it does not provide a way for specifying own ppp unit id.
      
      If some network interface (does not have to be ppp) has name "ppp<id>"
      with this first free ppp id then PPPIOCNEWUNIT ioctl or rtnl call fails.
      
      And registering new ppp interface is not possible anymore, until interface
      which holds conflicting name is renamed. Or when using rtnl method with
      custom interface name in IFLA_IFNAME.
      
      As list of allocated / used ppp unit ids is not possible to retrieve from
      kernel to userspace, userspace has no idea what happens nor which interface
      is doing this conflict.
      
      So change the algorithm how ppp unit id is generated. And choose the first
      number which is not neither used as ppp unit id nor in some network
      interface with pattern "ppp<id>".
      
      This issue can be simply reproduced by following pppd call when there is no
      ppp interface registered and also no interface with name pattern "ppp<id>":
      
          pppd ifname ppp1 +ipv6 noip noauth nolock local nodetach pty "pppd +ipv6 noip noauth nolock local nodetach notty"
      
      Or by creating the one ppp interface (which gets assigned ppp unit id 0),
      renaming it to "ppp1" and then trying to create a new ppp interface (which
      will always fails as next free ppp unit id is 1, but network interface with
      name "ppp1" exists).
      
      This patch fixes above described issue by generating new and new ppp unit
      id until some non-conflicting id with network interfaces is generated.
      
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dee5b011
    • Longfang Liu's avatar
      USB:ehci:fix Kunpeng920 ehci hardware problem · c973b4e2
      Longfang Liu authored
      commit 26b75952
      
       upstream.
      
      Kunpeng920's EHCI controller does not have SBRN register.
      Reading the SBRN register when the controller driver is
      initialized will get 0.
      
      When rebooting the EHCI driver, ehci_shutdown() will be called.
      if the sbrn flag is 0, ehci_shutdown() will return directly.
      The sbrn flag being 0 will cause the EHCI interrupt signal to
      not be turned off after reboot. this interrupt that is not closed
      will cause an exception to the device sharing the interrupt.
      
      Therefore, the EHCI controller of Kunpeng920 needs to skip
      the read operation of the SBRN register.
      
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarLongfang Liu <liulongfang@huawei.com>
      Link: https://lore.kernel.org/r/1617958081-17999-1-git-send-email-liulongfang@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c973b4e2
    • Letu Ren's avatar
      net/qla3xxx: fix schedule while atomic in ql_wait_for_drvr_lock and ql_adapter_reset · 1dab1f6c
      Letu Ren authored
      [ Upstream commit 92766c46
      
       ]
      
      When calling the 'ql_wait_for_drvr_lock' and 'ql_adapter_reset', the driver
      has already acquired the spin lock, so the driver should not call 'ssleep'
      in atomic context.
      
      This bug can be fixed by using 'mdelay' instead of 'ssleep'.
      
      Reported-by: default avatarLetu Ren <fantasquex@gmail.com>
      Signed-off-by: default avatarLetu Ren <fantasquex@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1dab1f6c
    • Prarit Bhargava's avatar
      alpha: Send stop IPI to send to online CPUs · 605ab007
      Prarit Bhargava authored
      [ Upstream commit caace6ca
      
       ]
      
      This issue was noticed while debugging a shutdown issue where some
      secondary CPUs are not being shutdown correctly.  A fix for that [1] requires
      that secondary cpus be offlined using the cpu_online_mask so that the
      stop operation is a no-op if CPU HOTPLUG is disabled.  I, like the author in
      [1] looked at the architectures and found that alpha is one of two
      architectures that executes smp_send_stop() on all possible CPUs.
      
      On alpha, smp_send_stop() sends an IPI to all possible CPUs but only needs
      to send them to online CPUs.
      
      Send the stop IPI to only the online CPUs.
      
      [1] https://lkml.org/lkml/2020/1/10/250
      
      Signed-off-by: default avatarPrarit Bhargava <prarit@redhat.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      605ab007
    • Shreyansh Chouhan's avatar
      reiserfs: check directory items on read from disk · c6deab07
      Shreyansh Chouhan authored
      [ Upstream commit 13d25750
      
       ]
      
      While verifying the leaf item that we read from the disk, reiserfs
      doesn't check the directory items, this could cause a crash when we
      read a directory item from the disk that has an invalid deh_location.
      
      This patch adds a check to the directory items read from the disk that
      does a bounds check on deh_location for the directory entries. Any
      directory entry header with a directory entry offset greater than the
      item length is considered invalid.
      
      Link: https://lore.kernel.org/r/20210709152929.766363-1-chouhan.shreyansh630@gmail.com
      Reported-by: default avatar <syzbot+c31a48e6702ccb3d64c9@syzkaller.appspotmail.com>
      Signed-off-by: default avatarShreyansh Chouhan <chouhan.shreyansh630@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c6deab07
    • Yu Kuai's avatar
      reiserfs: add check for root_inode in reiserfs_fill_super · a86ec855
      Yu Kuai authored
      [ Upstream commit 2acf15b9
      
       ]
      
      Our syzcaller report a NULL pointer dereference:
      
      BUG: kernel NULL pointer dereference, address: 0000000000000000
      PGD 116e95067 P4D 116e95067 PUD 1080b5067 PMD 0
      Oops: 0010 [#1] SMP KASAN
      CPU: 7 PID: 592 Comm: a.out Not tainted 5.13.0-next-20210629-dirty #67
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-p4
      RIP: 0010:0x0
      Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
      RSP: 0018:ffff888114e779b8 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: 1ffff110229cef39 RCX: ffffffffaa67e1aa
      RDX: 0000000000000000 RSI: ffff88810a58ee00 RDI: ffff8881233180b0
      RBP: ffffffffac38e9c0 R08: ffffffffaa67e17e R09: 0000000000000001
      R10: ffffffffb91c5557 R11: fffffbfff7238aaa R12: ffff88810a58ee00
      R13: ffff888114e77aa0 R14: 0000000000000000 R15: ffff8881233180b0
      FS:  00007f946163c480(0000) GS:ffff88839f1c0000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: ffffffffffffffd6 CR3: 00000001099c1000 CR4: 00000000000006e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       __lookup_slow+0x116/0x2d0
       ? page_put_link+0x120/0x120
       ? __d_lookup+0xfc/0x320
       ? d_lookup+0x49/0x90
       lookup_one_len+0x13c/0x170
       ? __lookup_slow+0x2d0/0x2d0
       ? reiserfs_schedule_old_flush+0x31/0x130
       reiserfs_lookup_privroot+0x64/0x150
       reiserfs_fill_super+0x158c/0x1b90
       ? finish_unfinished+0xb10/0xb10
       ? bprintf+0xe0/0xe0
       ? __mutex_lock_slowpath+0x30/0x30
       ? __kasan_check_write+0x20/0x30
       ? up_write+0x51/0xb0
       ? set_blocksize+0x9f/0x1f0
       mount_bdev+0x27c/0x2d0
       ? finish_unfinished+0xb10/0xb10
       ? reiserfs_kill_sb+0x120/0x120
       get_super_block+0x19/0x30
       legacy_get_tree+0x76/0xf0
       vfs_get_tree+0x49/0x160
       ? capable+0x1d/0x30
       path_mount+0xacc/0x1380
       ? putname+0x97/0xd0
       ? finish_automount+0x450/0x450
       ? kmem_cache_free+0xf8/0x5a0
       ? putname+0x97/0xd0
       do_mount+0xe2/0x110
       ? path_mount+0x1380/0x1380
       ? copy_mount_options+0x69/0x140
       __x64_sys_mount+0xf0/0x190
       do_syscall_64+0x35/0x80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      This is because 'root_inode' is initialized with wrong mode, and
      it's i_op is set to 'reiserfs_special_inode_operations'. Thus add
      check for 'root_inode' to fix the problem.
      
      Link: https://lore.kernel.org/r/20210702040743.1918552-1-yukuai3@huawei.com
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a86ec855
    • Like Xu's avatar
      perf/x86/amd: Don't touch the AMD64_EVENTSEL_HOSTONLY bit inside the guest · 16b9d4d7
      Like Xu authored
      commit df51fe7e upstream.
      
      If we use "perf record" in an AMD Milan guest, dmesg reports a #GP
      warning from an unchecked MSR access error on MSR_F15H_PERF_CTLx:
      
        [] unchecked MSR access error: WRMSR to 0xc0010200 (tried to write 0x0000020000110076) at rIP: 0xffffffff8106ddb4 (native_write_msr+0x4/0x20)
        [] Call Trace:
        []  amd_pmu_disable_event+0x22/0x90
        []  x86_pmu_stop+0x4c/0xa0
        []  x86_pmu_del+0x3a/0x140
      
      The AMD64_EVENTSEL_HOSTONLY bit is defined and used on the host,
      while the guest perf driver should avoid such use.
      
      Fixes: 1018faa6
      
       ("perf/x86/kvm: Fix Host-Only/Guest-Only counting with SVM disabled")
      Signed-off-by: default avatarLike Xu <likexu@tencent.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarLiam Merwick <liam.merwick@oracle.com>
      Tested-by: default avatarKim Phillips <kim.phillips@amd.com>
      Tested-by: default avatarLiam Merwick <liam.merwick@oracle.com>
      Link: https://lkml.kernel.org/r/20210802070850.35295-1-likexu@tencent.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16b9d4d7
    • Zheyu Ma's avatar
      pcmcia: i82092: fix a null pointer dereference bug · b84e587e
      Zheyu Ma authored
      commit e39cdacf
      
       upstream.
      
      During the driver loading process, the 'dev' field was not assigned, but
      the 'dev' field was referenced in the subsequent 'i82092aa_set_mem_map'
      function.
      
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      CC: <stable@vger.kernel.org>
      [linux@dominikbrodowski.net: shorten commit message, add Cc to stable]
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b84e587e
    • Maciej W. Rozycki's avatar
      MIPS: Malta: Do not byte-swap accesses to the CBUS UART · d410896e
      Maciej W. Rozycki authored
      commit 9a936d6c upstream.
      
      Correct big-endian accesses to the CBUS UART, a Malta on-board discrete
      TI16C550C part wired directly to the system controller's device bus, and
      do not use byte swapping with the 32-bit accesses to the device.
      
      The CBUS is used for devices such as the boot flash memory needed early
      on in system bootstrap even before PCI has been initialised.  Therefore
      it uses the system controller's device bus, which follows the endianness
      set with the CPU, which means no byte-swapping is ever required for data
      accesses to CBUS, unlike with PCI.
      
      The CBUS UART uses the UPIO_MEM32 access method, that is the `readl' and
      `writel' MMIO accessors, which on the MIPS platform imply byte-swapping
      with PCI systems.  Consequently the wrong byte lane is accessed with the
      big-endian configuration and the UART is not correctly accessed.
      
      As it happens the UPIO_MEM32BE access method makes use of the `ioread32'
      and `iowrite32' MMIO accessors, which still use `readl' and `writel'
      respectively, however they byte-swap data passed, effectively cancelling
      swapping done with the accessors themselves and making it suitable for
      the CBUS UART.
      
      Make the CBUS UART switch between UPIO_MEM32 and UPIO_MEM32BE then,
      based on the endianness selected.  With this change in place the device
      is correctly recognised with big-endian Malta at boot, along with the
      Super I/O devices behind PCI:
      
      Serial: 8250/16550 driver, 5 ports, IRQ sharing enabled
      printk: console [ttyS0] disabled
      serial8250.0: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
      printk: console [ttyS0] enabled
      printk: bootconsole [uart8250] disabled
      serial8250.0: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
      serial8250.0: ttyS2 at MMIO 0x1f000900 (irq = 20, base_baud = 230400) is a 16550A
      
      Fixes: e7c4782f
      
       ("[MIPS] Put an end to <asm/serial.h>'s long and annyoing existence")
      Cc: stable@vger.kernel.org # v2.6.23+
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106260524430.37803@angie.orcam.me.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d410896e
    • Maciej W. Rozycki's avatar
      serial: 8250: Mask out floating 16/32-bit bus bits · 3504317f
      Maciej W. Rozycki authored
      commit e5227c51 upstream.
      
      Make sure only actual 8 bits of the IIR register are used in determining
      the port type in `autoconfig'.
      
      The `serial_in' port accessor returns the `unsigned int' type, meaning
      that with UPIO_AU, UPIO_MEM16, UPIO_MEM32, and UPIO_MEM32BE access types
      more than 8 bits of data are returned, of which the high order bits will
      often come from bus lines that are left floating in the data phase.  For
      example with the MIPS Malta board's CBUS UART, where the registers are
      aligned on 8-byte boundaries and which uses 32-bit accesses, data as
      follows is returned:
      
      YAMON> dump -32 0xbf000900 0x40
      
      BF000900: 1F000942 1F000942 1F000900 1F000900  ...B...B........
      BF000910: 1F000901 1F000901 1F000900 1F000900  ................
      BF000920: 1F000900 1F000900 1F000960 1F000960  ...........`...`
      BF000930: 1F000900 1F000900 1F0009FF 1F0009FF  ................
      
      YAMON>
      
      Evidently high-order 24 bits return values previously driven in the
      address phase (the 3 highest order address bits used with the command
      above are masked out in the simple virtual address mapping used here and
      come out at zeros on the external bus), a common scenario with bus lines
      left floating, due to bus capacitance.
      
      Consequently when the value of IIR, mapped at 0x1f000910, is retrieved
      in `autoconfig', it comes out at 0x1f0009c1 and when it is right-shifted
      by 6 and then assigned to 8-bit `scratch' variable, the value calculated
      is 0x27, not one of 0, 1, 2, 3 expected in port type determination.
      
      Fix the issue then, by assigning the value returned from `serial_in' to
      `scratch' first, which masks out 24 high-order bits retrieved, and only
      then right-shift the resulting 8-bit data quantity, producing the value
      of 3 in this case, as expected.  Fix the same issue in `serial_dl_read'.
      
      The problem first appeared with Linux 2.6.9-rc3 which predates our repo
      history, but the origin could be identified with the old MIPS/Linux repo
      also at: <git://git.kernel.org/pub/scm/linux/kernel/git/ralf/linux.git>
      as commit e0d2356c0777 ("Merge with Linux 2.6.9-rc3."), where code in
      `serial_in' was updated with this case:
      
      +	case UPIO_MEM32:
      +		return readl(up->port.membase + offset);
      +
      
      which made it produce results outside the unsigned 8-bit range for the
      first time, though obviously it is system dependent what actual values
      appear in the high order bits retrieved and it may well have been zeros
      in the relevant positions with the system the change originally was
      intended for.  It is at that point that code in `autoconf' should have
      been updated accordingly, but clearly it was overlooked.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Cc: stable@vger.kernel.org # v2.6.12+
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106260516220.37803@angie.orcam.me.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3504317f
    • Alex Xu (Hello71)'s avatar
      pipe: increase minimum default pipe size to 2 pages · 2112e5d1
      Alex Xu (Hello71) authored
      commit 46c4c9d1 upstream.
      
      This program always prints 4096 and hangs before the patch, and always
      prints 8192 and exits successfully after:
      
        int main()
        {
            int pipefd[2];
            for (int i = 0; i < 1025; i++)
                if (pipe(pipefd) == -1)
                    return 1;
            size_t bufsz = fcntl(pipefd[1], F_GETPIPE_SZ);
            printf("%zd\n", bufsz);
            char *buf = calloc(bufsz, 1);
            write(pipefd[1], buf, bufsz);
            read(pipefd[0], buf, bufsz-1);
            write(pipefd[1], buf, 1);
        }
      
      Note that you may need to increase your RLIMIT_NOFILE before running the
      program.
      
      Fixes: 759c0114
      
       ("pipe: limit the per-user amount of pages allocated in pipes")
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/lkml/1628086770.5rn8p04n6j.none@localhost/
      Link: https://lore.kernel.org/lkml/1628127094.lxxn016tj7.none@localhost/
      Signed-off-by: default avatarAlex Xu (Hello71) <alex_y_xu@yahoo.ca>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2112e5d1
    • Johan Hovold's avatar
      media: rtl28xxu: fix zero-length control request · f8bb00fd
      Johan Hovold authored
      commit 76f22c93
      
       upstream.
      
      The direction of the pipe argument must match the request-type direction
      bit or control requests may fail depending on the host-controller-driver
      implementation.
      
      Control transfers without a data stage are treated as OUT requests by
      the USB stack and should be using usb_sndctrlpipe(). Failing to do so
      will now trigger a warning.
      
      The driver uses a zero-length i2c-read request for type detection so
      update the control-request code to use usb_sndctrlpipe() in this case.
      
      Note that actually trying to read the i2c register in question does not
      work as the register might not exist (e.g. depending on the demodulator)
      as reported by Eero Lehtinen <debiangamer2@gmail.com>.
      
      Reported-by: default avatar <syzbot+faf11bbadc5a372564da@syzkaller.appspotmail.com>
      Reported-by: default avatarEero Lehtinen <debiangamer2@gmail.com>
      Tested-by: default avatarEero Lehtinen <debiangamer2@gmail.com>
      Fixes: d0f232e8
      
       ("[media] rtl28xxu: add heuristic to detect chip type")
      Cc: stable@vger.kernel.org      # 4.0
      Cc: Antti Palosaari <crope@iki.fi>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8bb00fd
    • Hui Su's avatar
      scripts/tracing: fix the bug that can't parse raw_trace_func · d4461884
      Hui Su authored
      commit 1c0cec64 upstream.
      
      Since commit 77271ce4 ("tracing: Add irq, preempt-count and need resched info
      to default trace output"), the default trace output format has been changed to:
                <idle>-0       [009] d.h. 22420.068695: _raw_spin_lock_irqsave <-hrtimer_interrupt
                <idle>-0       [000] ..s. 22420.068695: _nohz_idle_balance <-run_rebalance_domains
                <idle>-0       [011] d.h. 22420.068695: account_process_tick <-update_process_times
      
      origin trace output format:(before v3.2.0)
           # tracer: nop
           #
           #           TASK-PID    CPU#    TIMESTAMP  FUNCTION
           #              | |       |          |         |
                migration/0-6     [000]    50.025810: rcu_note_context_switch <-__schedule
                migration/0-6     [000]    50.025812: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025813: rcu_sched_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025815: rcu_preempt_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025817: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025818: debug_lockdep_rcu_enabled <-__schedule
                migration/0-6     [000]    50.025820: debug_lockdep_rcu_enabled <-__schedule
      
      The draw_functrace.py(introduced in v2.6.28) can't parse the new version format trace_func,
      So we need modify draw_functrace.py to adapt the new version trace output format.
      
      Link: https://lkml.kernel.org/r/20210611022107.608787-1-suhui@zeku.com
      
      Cc: stable@vger.kernel.org
      Fixes: 77271ce4
      
       tracing: Add irq, preempt-count and need resched info to default trace output
      Signed-off-by: default avatarHui Su <suhui@zeku.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d4461884
    • Dmitry Osipenko's avatar
      usb: otg-fsm: Fix hrtimer list corruption · 22b3cc0f
      Dmitry Osipenko authored
      commit bf88fef0
      
       upstream.
      
      The HNP work can be re-scheduled while it's still in-fly. This results in
      re-initialization of the busy work, resetting the hrtimer's list node of
      the work and crashing kernel with null dereference within kernel/timer
      once work's timer is expired. It's very easy to trigger this problem by
      re-plugging USB cable quickly. Initialize HNP work only once to fix this
      trouble.
      
       Unable to handle kernel NULL pointer dereference at virtual address 00000126)
       ...
       PC is at __run_timers.part.0+0x150/0x228
       LR is at __next_timer_interrupt+0x51/0x9c
       ...
       (__run_timers.part.0) from [<c0187a2b>] (run_timer_softirq+0x2f/0x50)
       (run_timer_softirq) from [<c01013ad>] (__do_softirq+0xd5/0x2f0)
       (__do_softirq) from [<c012589b>] (irq_exit+0xab/0xb8)
       (irq_exit) from [<c0170341>] (handle_domain_irq+0x45/0x60)
       (handle_domain_irq) from [<c04c4a43>] (gic_handle_irq+0x6b/0x7c)
       (gic_handle_irq) from [<c0100b65>] (__irq_svc+0x65/0xac)
      
      Cc: stable@vger.kernel.org
      Acked-by: default avatarPeter Chen <peter.chen@kernel.org>
      Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Link: https://lore.kernel.org/r/20210717182134.30262-6-digetx@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22b3cc0f
    • David Bauer's avatar
      USB: serial: ftdi_sio: add device ID for Auto-M3 OP-COM v2 · 384ea57a
      David Bauer authored
      commit 8da0e55c
      
       upstream.
      
      The Auto-M3 OP-COM v2 is a OBD diagnostic device using a FTD232 for the
      USB connection.
      
      Signed-off-by: default avatarDavid Bauer <mail@david-bauer.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      384ea57a
    • Willy Tarreau's avatar
      USB: serial: ch341: fix character loss at high transfer rates · fa74dfe8
      Willy Tarreau authored
      commit 3c18e9ba
      
       upstream.
      
      The chip supports high transfer rates, but with the small default buffers
      (64 bytes read), some entire blocks are regularly lost. This typically
      happens at 1.5 Mbps (which is the default speed on Rockchip devices) when
      used as a console to access U-Boot where the output of the "help" command
      misses many lines and where "printenv" mangles the environment.
      
      The FTDI driver doesn't suffer at all from this. One difference is that
      it uses 512 bytes rx buffers and 256 bytes tx buffers. Adopting these
      values completely resolved the issue, even the output of "dmesg" is
      reliable. I preferred to leave the Tx value unchanged as it is not
      involved in this issue, while a change could increase the risk of
      triggering the same issue with other devices having too small buffers.
      
      I verified that it backports well (and works) at least to 5.4. It's of
      low importance enough to be dropped where it doesn't trivially apply
      anymore.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      Link: https://lore.kernel.org/r/20210724152739.18726-1-w@1wt.eu
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa74dfe8
    • Daniele Palmas's avatar
      USB: serial: option: add Telit FD980 composition 0x1056 · f4d6c9b3
      Daniele Palmas authored
      commit 5648c073
      
       upstream.
      
      Add the following Telit FD980 composition 0x1056:
      
      Cfg #1: mass storage
      Cfg #2: rndis, tty, adb, tty, tty, tty, tty
      
      Signed-off-by: default avatarDaniele Palmas <dnlplm@gmail.com>
      Link: https://lore.kernel.org/r/20210803194711.3036-1-dnlplm@gmail.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>
      f4d6c9b3
    • Qiang.zhang's avatar
      USB: usbtmc: Fix RCU stall warning · adfb8b54
      Qiang.zhang authored
      commit 30fad76c upstream.
      
      rcu: INFO: rcu_preempt self-detected stall on CPU
      rcu:    1-...!: (2 ticks this GP) idle=d92/1/0x4000000000000000
              softirq=25390/25392 fqs=3
              (t=12164 jiffies g=31645 q=43226)
      rcu: rcu_preempt kthread starved for 12162 jiffies! g31645 f0x0
           RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0
      rcu:    Unless rcu_preempt kthread gets sufficient CPU time,
              OOM is now expected behavior.
      rcu: RCU grace-period kthread stack dump:
      task:rcu_preempt     state:R  running task
      ...........
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: usb_submit_urb failed: -19
      
      The function usbtmc_interrupt() resubmits urbs when the error status
      of an urb is -EPROTO. In systems using the dummy_hcd usb controller
      this can result in endless interrupt loops when the usbtmc device is
      disconnected from the host system.
      
      Since host controller drivers already try to recover from transmission
      errors, there is no need to resubmit the urb or try other solutions
      to repair the error situation.
      
      In case of errors the INT pipe just stops to wait for further packets.
      
      Fixes: dbf3e7f6
      
       ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation")
      Cc: stable@vger.kernel.org
      Reported-by: default avatar <syzbot+e2eae5639e7203360018@syzkaller.appspotmail.com>
      Signed-off-by: default avatarQiang.zhang <qiang.zhang@windriver.com>
      Acked-by: default avatarGuido Kiener <guido.kiener@rohde-schwarz.com>
      Link: https://lore.kernel.org/r/20210723004334.458930-1-qiang.zhang@windriver.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      adfb8b54
    • Tetsuo Handa's avatar
      Bluetooth: defer cleanup of resources in hci_unregister_dev() · 0e77f979
      Tetsuo Handa authored
      [ Upstream commit e0448092 ]
      
      syzbot is hitting might_sleep() warning at hci_sock_dev_event() due to
      calling lock_sock() with rw spinlock held [1].
      
      It seems that history of this locking problem is a trial and error.
      
      Commit b40df574 ("[PATCH] bluetooth: fix socket locking in
      hci_sock_dev_event()") in 2.6.21-rc4 changed bh_lock_sock() to
      lock_sock() as an attempt to fix lockdep warning.
      
      Then, commit 4ce61d1c ("[BLUETOOTH]: Fix locking in
      hci_sock_dev_event().") in 2.6.22-rc2 changed lock_sock() to
      local_bh_disable() + bh_lock_sock_nested() as an attempt to fix the
      sleep in atomic context warning.
      
      Then, commit 4b5dd696 ("Bluetooth: Remove local_bh_disable() from
      hci_sock.c") in 3.3-rc1 removed local_bh_disable().
      
      Then, commit e305509e
      
       ("Bluetooth: use correct lock to prevent UAF
      of hdev object") in 5.13-rc5 again changed bh_lock_sock_nested() to
      lock_sock() as an attempt to fix CVE-2021-3573.
      
      This difficulty comes from current implementation that
      hci_sock_dev_event(HCI_DEV_UNREG) is responsible for dropping all
      references from sockets because hci_unregister_dev() immediately
      reclaims resources as soon as returning from
      hci_sock_dev_event(HCI_DEV_UNREG).
      
      But the history suggests that hci_sock_dev_event(HCI_DEV_UNREG) was not
      doing what it should do.
      
      Therefore, instead of trying to detach sockets from device, let's accept
      not detaching sockets from device at hci_sock_dev_event(HCI_DEV_UNREG),
      by moving actual cleanup of resources from hci_unregister_dev() to
      hci_cleanup_dev() which is called by bt_host_release() when all
      references to this unregistered device (which is a kobject) are gone.
      
      Since hci_sock_dev_event(HCI_DEV_UNREG) no longer resets
      hci_pi(sk)->hdev, we need to check whether this device was unregistered
      and return an error based on HCI_UNREGISTER flag.  There might be subtle
      behavioral difference in "monitor the hdev" functionality; please report
      if you found something went wrong due to this patch.
      
      Link: https://syzkaller.appspot.com/bug?extid=a5df189917e79d5e59c9 [1]
      Reported-by: default avatarsyzbot <syzbot+a5df189917e79d5e59c9@syzkaller.appspotmail.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Fixes: e305509e
      
       ("Bluetooth: use correct lock to prevent UAF of hdev object")
      Acked-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0e77f979
    • Pavel Skripkin's avatar
      net: vxge: fix use-after-free in vxge_device_unregister · 4e1c0ac9
      Pavel Skripkin authored
      [ Upstream commit 942e560a ]
      
      Smatch says:
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3518 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3518 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3520 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3520 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      
      Since vdev pointer is netdev private data accessing it after free_netdev()
      call can cause use-after-free bug. Fix it by moving free_netdev() call at
      the end of the function
      
      Fixes: 6cca2003
      
       ("vxge: cleanup probe error paths")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4e1c0ac9
    • Pavel Skripkin's avatar
      net: fec: fix use-after-free in fec_drv_remove · cc26cccc
      Pavel Skripkin authored
      [ Upstream commit 44712965
      
       ]
      
      Smatch says:
      	drivers/net/ethernet/freescale/fec_main.c:3994 fec_drv_remove() error: Using fep after free_{netdev,candev}(ndev);
      	drivers/net/ethernet/freescale/fec_main.c:3995 fec_drv_remove() error: Using fep after free_{netdev,candev}(ndev);
      
      Since fep pointer is netdev private data, accessing it after free_netdev()
      call can cause use-after-free bug. Fix it by moving free_netdev() call at
      the end of the function
      
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Fixes: a31eda65
      
       ("net: fec: fix clock count mis-match")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cc26cccc
    • Pavel Skripkin's avatar
      net: pegasus: fix uninit-value in get_interrupt_interval · 10fb322e
      Pavel Skripkin authored
      [ Upstream commit af35fc37
      
       ]
      
      Syzbot reported uninit value pegasus_probe(). The problem was in missing
      error handling.
      
      get_interrupt_interval() internally calls read_eprom_word() which can
      fail in some cases. For example: failed to receive usb control message.
      These cases should be handled to prevent uninit value bug, since
      read_eprom_word() will not initialize passed stack variable in case of
      internal failure.
      
      Fail log:
      
      BUG: KMSAN: uninit-value in get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline]
      BUG: KMSAN: uninit-value in pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152
      CPU: 1 PID: 825 Comm: kworker/1:1 Not tainted 5.12.0-rc6-syzkaller #0
      ...
      Workqueue: usb_hub_wq hub_event
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0x24c/0x2e0 lib/dump_stack.c:120
       kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x5c/0xa0 mm/kmsan/kmsan_instr.c:197
       get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline]
       pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152
      ....
      
      Local variable ----data.i@pegasus_probe created at:
       get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline]
       pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152
       get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline]
       pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152
      
      Reported-and-tested-by: default avatar <syzbot+02c9f70f3afae308464a@syzkaller.appspotmail.com>
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Link: https://lore.kernel.org/r/20210804143005.439-1-paskripkin@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      10fb322e
    • Dan Carpenter's avatar
      bnx2x: fix an error code in bnx2x_nic_load() · 8342f746
      Dan Carpenter authored
      [ Upstream commit fb653827 ]
      
      Set the error code if bnx2x_alloc_fw_stats_mem() fails.  The current
      code returns success.
      
      Fixes: ad5afc89
      
       ("bnx2x: Separate VF and PF logic")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8342f746
    • H. Nikolaus Schaller's avatar
      mips: Fix non-POSIX regexp · 6ce34831
      H. Nikolaus Schaller authored
      [ Upstream commit 28bbbb98 ]
      
      When cross compiling a MIPS kernel on a BSD based HOSTCC leads
      to errors like
      
        SYNC    include/config/auto.conf.cmd - due to: .config
      egrep: empty (sub)expression
        UPD     include/config/kernel.release
        HOSTCC  scripts/dtc/dtc.o - due to target missing
      
      It turns out that egrep uses this egrep pattern:
      
      		(|MINOR_|PATCHLEVEL_)
      
      This is not valid syntax or gives undefined results according
      to POSIX 9.5.3 ERE Grammar
      
      	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
      
      It seems to be silently accepted by the Linux egrep implementation
      while a BSD host complains.
      
      Such patterns can be replaced by a transformation like
      
      	"(|p1|p2)" -> "(p1|p2)?"
      
      Fixes: 48c35b2d
      
       ("[MIPS] There is no __GNUC_MAJOR__")
      Signed-off-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ce34831